Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colors on log file #77

Open
riccardomanfrin opened this issue Aug 31, 2021 · 2 comments
Open

colors on log file #77

riccardomanfrin opened this issue Aug 31, 2021 · 2 comments

Comments

@riccardomanfrin
Copy link

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?

@fireproofsocks
Copy link
Collaborator

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.

@tomekowal
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants