2013-03-28 26 views
18

輸出:如何着色Multitail中的Rails日誌?在XFCE終端<code>tail logs/development.log</code>

output of tail logs/development.log in XFCE Terminal

multitail log/development.log 

output of 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產生非可用輸出。

Output of multitail -c

如何上色在Multitail日誌,而無需編寫自己的配色方案?

回答

27

這是所有關於解釋哪些不做終端而不是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 

colorized output of multitail -cT ansi log/development.log

+2

我再次一派,現在想再次給予好評...謝謝! –

+3

我很高興它有幫助。其實這是回答自己的問題的主要原因 - 稍後找到它;) –