daroczig/logger

skip_formater does not work for the second argument

vspinu opened this issue · 3 comments

This works:

> log_error(skip_formatter("{\"x\": [\"a\"]}"))
ERROR [2021-05-07 16:40:14] {"x": ["a"]}

This does not work:

> log_error("xxx:", skip_formatter("{\"x\": [\"a\"]}"))
Error in value[[3L]](cond) : `glue` failed in `formatter_glue` on:

  chr "xxx:" 

Raw error message:

 <text>:1:6: unexpected '['
1: "x": [
         ^ 

Please consider using another `log_formatter` or `skip_formatter` on strings with curly braces.

Hm, probably this is a documentation problem, but a formatter fn runs on ... as-is, and not separately for each element of .... In other words, the default formatter_glue will take all ... params, so glue will fail.

The skip_formatter approach only works if that's the only (string) object passed, like in your first example.

Not sure who to try to explain this better .. does it make sense?

I see, so ... are just passed to formatter as is then?

Then I would expect this to work

> log_error(skip_formatter("xxx:"), "{\"x\": [\"a\"]}")
ERROR [2021-05-08 11:24:38] xxx:

skip_formater should mean that the default, plain formatter (paste?) is run on the entire thing including ....

the formater_glue_or_sprintf suits my needs really well actually. So I think this issue can be treated as a documentation issue indeed.