emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
315 stars 55 forks source link

Add Additional Primary Writer #32

Closed raytiley closed 5 years ago

raytiley commented 5 years ago

I might be missing something but it seems like the add_writer requires calling all the logging macros with a target. I can't see any way to add an additional writer that always get's used.

Would adding some way to add writers that always get logged to be accepted?

My use case is I want to write a custom writer for the windows event viewer but also use the file log writer to keep text logs for my application.

Thanks!

emabee commented 5 years ago

The additional writers are special in two regards:

Or put the other way: the log specification only influences the default logger.

How would you want it for your "sibling of the default writer" - filtered by the log specification, or always called? In the latter case, your implementation could still have its own filtering mechanism, but this additional flexibility would come with increased overall complexity.

emabee commented 5 years ago

I provided an implementation in branch add_default_writer. Would be great if you could test it and give feedback!

fin-ger commented 5 years ago

I think the additional default writer should inherit the log specification from the default writer. I think this is the expected behavior by users.

fin-ger commented 5 years ago

@emabee I tested the add_default_writer branch and it worked like a charm!

emabee commented 5 years ago

Great, thanks! I just published 0.14.3 with the change from add_default_writer.