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

Cannot configure colors per-destination #68

Open
rmolinari opened this issue Nov 27, 2019 · 0 comments
Open

Cannot configure colors per-destination #68

rmolinari opened this issue Nov 27, 2019 · 0 comments

Comments

@rmolinari
Copy link

In my application I send log messages to a file. Messages are optionally sent to stderr based on a command line argument.

Compile-time config:
chronicles_sinks=textlines[file(dancing_links.log),dynamic]

Runtime:

if verbose:
  defaultChroniclesStream.outputs[1].writer =
    proc (logLevel: LogLevel, msg: LogOutputStr) {.gcsafe.} =
      stderr.write(msg)
else:
  defaultChroniclesStream.outputs[1].writer =
    proc (logLevel: LogLevel, msg: LogOutputStr) {.gcsafe.} =
      discard

This works. But I would like to see colors in the log file but not in stderr, because I sometimes want to pipe that into grep, sed, etc. But the nocolors property can't be specified on a per-destination basis.

This doesn't work:
chronicles_sinks=textlines[file(dancing_links.log),dynamic(nocolors)]

This does work, but now neither destination gets colors.
chronicles_sinks=textlines[nocolors,file(dancing_links.log),dynamic]

Is there a way to specify this at compile time, or to strip out the colors in the dynamic writer?

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

1 participant