如何在Multitail中着色Rails日志?

时间:2022-02-09 06:22:13

Output of tail logs/development.log in XFCE Terminal:

在XFCE终端输出tail logs / development.log:

如何在Multitail中着色Rails日志?

multitail log/development.log

如何在Multitail中着色Rails日志?

Rails adds escape codes to log files automatically. See development.log file:

Rails会自动将转义码添加到日志文件中。请参阅development.log文件:

  ^[[1m^[[36m (84.1ms)^[[0m  ^[[1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) ^[[0m
  ^[[1m^[[35m (92.6ms)^[[0m  CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
  ^[[1m^[[36m (0.2ms)^[[0m  ^[[1mSELECT version FROM "schema_migrations"^[[0m
  ^[[1m^[[35m (159.3ms)^[[0m  INSERT INTO "schema_migrations" (version) VALUES ('20130327221553')
  ^[[1m^[[36m (59.9ms)^[[0m  ^[[1mINSERT INTO "schema_migrations" (version) VALUES ('20130326152730')^[[0m
  ^[[1m^[[35m (59.8ms)^[[0m  INSERT INTO "schema_migrations" (version) VALUES ('20130327173637')

multitail -c produce non-usable output.

multitail -c产生不可用的输出。

如何在Multitail中着色Rails日志?

How to colorize logs in Multitail without writing own color scheme?

如何在不编写自己的配色方案的情况下为Multitail中的日志着色?

1 个解决方案

#1


27  

It's all about interpreting ANSI escape sequences which does terminal not tail itself and have to do multitail as well. It can be done with -cT ANSI option:

所有这些都是关于解释ANSI转义序列,它终端不会尾随,也必须做多线程。它可以使用-cT ANSI选项完成:

-cT term    interpret terminal-codes from file/command (for terminal type 'term')

Example:

例:

$ multitail -cT ansi log/development.log
multiple files:
$ multitail -cT ansi log/development.log -cT ANSI log/test.log

如何在Multitail中着色Rails日志?

#1


27  

It's all about interpreting ANSI escape sequences which does terminal not tail itself and have to do multitail as well. It can be done with -cT ANSI option:

所有这些都是关于解释ANSI转义序列,它终端不会尾随,也必须做多线程。它可以使用-cT ANSI选项完成:

-cT term    interpret terminal-codes from file/command (for terminal type 'term')

Example:

例:

$ multitail -cT ansi log/development.log
multiple files:
$ multitail -cT ansi log/development.log -cT ANSI log/test.log

如何在Multitail中着色Rails日志?