ryapric / loggit

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

Allow custom naming for default fields #4

Open nihonjinrxs opened 6 years ago

nihonjinrxs commented 6 years ago

In order to allow for conformance to a corporate logging standard, it would be helpful to allow renaming the default log fields in a configuration block of some sort.

For example, Usually, I need to write log_lvl with the key level and log_msg with the key msg. While I can do that now by adding those keys at the end, it seems I'll I end up having extra keys I don't use.

ryapric commented 6 years ago

The challenge with this, is that many functions currently depend on those field names being the defaults, as well as those function's arguments. Depending on your deployment scenario, though, you don't need to add new fields; you can just replace the fields, e.g. even at a native level with sed:

sed -i 's/log_lvl/level/g' loggit.json

Obviously not as robust when you want to write to a stream connection, but that's a quick fix for when using it the default way. Adding to enhancements list regardless.

nihonjinrxs commented 6 years ago

We stream logs to stdout of the container, and container log streams are piped to a logstash instance, so would be really nice not to have to munge things after the fact. Thanks for adding this to the enhancements list.

ryapric commented 4 years ago

Update that I'm still not super sure about this one, but will explore as I work on v2.0.0. Maybe just add a function arg to rename before output. It would put a lot of onus on the developer to maintain naming consistency, though, and there's a fine line between flexibility and shared-responsibility. But, will keep open for now.

ryapric commented 4 years ago

Removing from v.2.0.0 milestone (but keeping open for others) due to complexity, and use-case dependence. The solution provided earlier is the best bet for now, despite it creating extra redundant keys:

For example, Usually, I need to write log_lvl with the key level and log_msg with the key msg. While I can do that now by adding those keys at the end, it seems I'll I end up having extra keys I don't use.