ruby-on-rails – 如何使用Multitail中的Rails日志进行着色?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何使用Multitail中的Rails日志进行着色?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
XFCE中尾部日志/ 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中的日志着色?

解决方法

这一切都是关于解释 ANSI escape sequences哪个终端不能自己尾随,也必须做多任务.
可以使用-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相关文章