Closed daroczig closed 7 months ago
hmm, in that case, maybe it's the description of '...' that's misleading?
https://github.com/daroczig/logger/blob/ec619ce09d4db7c428745f8152a05907b92cdae9/R/logger.R#L214
I'm not sure if that's misleading, but suggestions welcomed. Formatters take the args and convert to string. Some formatters support named args .. but those are still R objects. If it's confusing, pls suggest better language 🙏
My initial read is that something like do.call(paste, within(lapply(list(...), as.character), sep = "")
would be done. Indeed that appears the case for un-named entries to ...
. But named arguments are handled differently -- they're used as an environment for substituting values into the unnamed parts of ...
(much like glue()
). So this distinction of named/unnamed parts of ...
is totally absent.
This is an instructive example I think:
log_info('{a}', '{a}{b}', '{a}{b}{c}', a=1, b=2, c=3)
# INFO [2024-02-28 16:21:37] 112123
After taking a look at the test results, and thinking this through more, I think failing on named args is not a viable solution, as there are many valid cases to pass named args, e.g. when using JSON loggers, or the below dummy example: