daroczig / logger

A lightweight, modern and flexible, log4j and futile.logger inspired logging utility for R
https://daroczig.github.io/logger
249 stars 38 forks source link

canonical way to remove an appender #149

Closed r2evans closed 4 months ago

r2evans commented 4 months ago

Sorry to bug you, but I can't find this in the docs ...

I have a long-running process that always logs to the console (appender_console) but occasionally jumped into some new subdirectory and I'd like it to be able to temporarily append (also) to a logfile in that subdirectory. Once that subdir's task is complete, I'd like to no longer append to that file (and never return to it).

I can add multiple appenders without problem, but without breaking into the internal namespaces environment, I don't know how to remove an appender completely.

Thoughts?

log_appender(appender_console)
log_info("normal")
log_appender(appender_file(somefile), index=2)
log_info("temporary") # goes to both the console and the file
log_appender(**DELETE**, index=2)
log_info("console only")
daroczig commented 4 months ago

This is actually something (I think) I've just pushed yesterday to your branch in #133 :)

https://github.com/daroczig/logger/pull/133/commits/f01b9763149149da67c228b20c5ff971c286d8ff

PS: if that PR looks good, I'll go ahead and merge all these and start testing for a CRAN release.

r2evans commented 4 months ago

Haha! Great minds think alike (I'm being presumptuous that I'm at least half as smart as you :-)

daroczig commented 4 months ago

lol 😂

agreed on the great minds think alike part, but if I was that smart .. I should have gone through all your awesome ideas and PRs years ago!