ryapric / loggit

Modern Logging for the R Ecosystem
Other
37 stars 2 forks source link

Enable explicit configuration to log to STDOUT #3

Closed nihonjinrxs closed 4 years ago

nihonjinrxs commented 6 years ago

In many of our production contexts, we log, usually in JSON, to STDOUT (or in rare cases STDERR), and have external log collectors that capture logs across many services.

The filename test in configurations.R seems to prevent me from doing what I'd normally do for this:

# gives me a writeable file handler for the standard output stream
log_file <- file("stdout", "w")

I think it would be helpful to allow for these basic streams as output.

This is also in concert with the logging factor of the 12-factor app, which recommends:

A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to stdout.

ryapric commented 6 years ago

Thanks for sharing that link! loggit does, and will always, default to file-based logging, as it's not explicitly designed for the use cases intended for that methodology:

The twelve-factor app is a methodology for building software-as-a-service apps [...]

But I can certainly see if I can get STDOUT logging to work as you describe, as an option.

nihonjinrxs commented 6 years ago

Would be appreciated, since most apps out there these days are software-as-a-service, also known as web apps and web apis.

ryapric commented 4 years ago

Note to self: I added an echo argument some time ago, but it doesn't log the JSON to stdout, just a regular text log entry. Need to configure to log the JSON. Will need to make sure the escaped quotes in the JSON aren't present in stdout.

ryapric commented 4 years ago

Done, will appear in v2.0.0.