Skip to content

formatter_glue fails when no unnamed arguments #130

@r2evans

Description

@r2evans

Occasionally I forget (i.e., when interactive) to set log_formatter(formatter_json). When this happens, any log messages that use named arguments will be blank. For instance,

log_info(quux="foo", a=pi)
# INFO [2023-11-18 19:50:26] 

where the initial intent was to have this:

log_formatter(formatter_json)
log_info(quux="foo", a=pi)
# INFO [2023-11-18 19:50:54] {"quux":"foo","a":3.1416}

I'm fine with the fact that part of the reason is that I forgot the formatter, but it would be nice if formatter_glue did not drop named arguments. I suggest the names can be dropped, and pasted together (with a space). Something like:

log_formatter(formatter_glue)
log_info(quux="foo", a=pi)
# INFO [2023-11-18 19:52:12] foo 3.14159265358979

Edit ... as I'm thinking about this, the purpose and layout of glue is rather simple, where unnamed objects are strings to format, and named objects are variables to use for substitution ... so I think the paste-ing above should only be done when none of ... are unnamed ... or perhaps just assume the first or first character or similar.

Bottom line, having it completely drop the message is perhaps not good. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions