Hi, I'd like to propose an addition of put_process_level(pid, level) into
the Logger module to allow controlling the runtime logging level on a
per-process basis.

Our app runs multiple background processing jobs that are performing data
sync. This means that the jobs run "forever". We're running a job (OTP
process) for each user. While we have metrics and alerts to understand when
a new user is hitting some bumps, we'd like to have detailed logs to help
debug any potential issues. The issues are mostly data-dependent and are
happening in the initial phase of the sync. After that, the issues rarely
ever happen and so the detailed logs are pretty useless, but they still
consume resources.

We could address our use case with something like the following:

new? = DateTime.diff(DateTime.utc_now(), sync_start) > @threshold
Logger.put_process_level(self(), if new?, do: :debug, else: :warn)

The implementation should be pretty straightforward and resemble the
implementation of Logger.enable/1.

Looking forward to your thoughts.


Best,
Stefan

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CACzMe7YxiOYc9esU68Db%2Bq7zwfixg2cJyYwb5X2tXdj6V52efw%40mail.gmail.com.

Reply via email to