loggit icon indicating copy to clipboard operation
loggit copied to clipboard

Allow custom naming for default fields

Open nihonjinrxs opened this issue 7 years ago • 4 comments

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.

nihonjinrxs avatar Sep 22 '18 15:09 nihonjinrxs

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.

ryapric avatar Sep 24 '18 15:09 ryapric

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.

nihonjinrxs avatar Nov 15 '18 03:11 nihonjinrxs

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 avatar Mar 15 '20 19:03 ryapric

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.

ryapric avatar May 04 '20 17:05 ryapric