Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to colorize Rails logs in Multitail?

Tags:

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

output of tail logs/development.log in XFCE Terminal

multitail log/development.log

output of multitail log/development.log

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

  ^[[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.

Output of multitail -c

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

like image 271
A.D. Avatar asked Mar 28 '13 19:03

A.D.


1 Answers

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:

-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

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

like image 174
A.D. Avatar answered Sep 18 '22 17:09

A.D.