onkel-dirtus/logger_file_backend

colors on log file

Opened this issue · 2 comments

I've got this config in my test.exs config

config :logger,
  backends: [{LoggerFileBackend, :test}]

config :logger, :test,
  colors: [enabled: true],
  path: "/tmp/test.log",
  level: :debug,
  format: "$time [$level] [$metadata] - $message\n",
  metadata: [:pid, :mfa, :file, :line]

but I can't see colorful logs in the file. Is this some unsupported feature for file logging?

Colors in the terminal are implemented via ANSI codes -- these are extra characters that get added. They are nice for iex sessions, but I don't think you want these written as literal output to a log file because they make parsing the log file that much more difficult.

I also thought about colours in log files.

My issue is that our application does lots of background jobs. In development, we make them run very often, and that produces a lot of logs. That was annoying when trying to type something in iex, so we've put the logs in a file that we can tail -f in a separate console.

For that use-case, having colours in the log would be lovely:+1:

If you find that feature useful, I am happy to contribute. If you still think that is not a great idea, let me know, and I'll find a workaround.

Thank you for your work on this fantastic project!