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

multitail log/development.log

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产生不可用的输出。

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

最佳答案

这全都是关于ANSI escape sequences的解释,它本身不是tail的终端,也必须执行multitail
可以使用-cT ANSI选项完成:

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

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

关于ruby-on-rails - 如何在Multitail中为Rails日志着色?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15690652/

10-09 06:10