Help Request
How to log from instances of a function/method/class/module to dynamically created sink only without same messages going to other sinks in application?
Is there a way to implement this scenario in current version (v0.1.6) of logly?
Or can it be considered as a reasonable feature request?
Context
Suppose I have a bunch of async tasks to run: tasks = [ myfunc("task1"), myfunc("task2"), ...]
await asyncio.wait_for( asyncio.gather(*tasks) )
I'm looking for a way to configure logly logger so that:
-
log messages from each task are written to corresponding file (separate sinks):
sink1 => logs/task1.log, sink2 => logs/task2.log, ...
with each file individually rotated, having independant log levels, etc.
-
log messages from these tasks don't go to any other sink configured in application
Using bind and fllter_function is not enough to implement such behaviour, because log messages are still propagated to other configured sinks and filter_function does not treat logs from instances of myfunc separately.
async def myfunc(taskname: str):
task_logger = logger.bind(name=taskname)
sink_id = task_logger.add(f"logs/{taskname}", filter_function="myfunc")
# .....
task_logger.remove(sink_id)
It is possible in python standard logging and in loguru (not trivial though).
Code Example
Logly Version
0.1.6
Python Version
3.10.12
Operating System
Ububtu 22.04
Additional Information
No response
Solution Interest
I just need help/guidance
Question Type
How-to questions
Specific Questions
No response
Checklist
Help Request
How to log from instances of a function/method/class/module to dynamically created sink only without same messages going to other sinks in application?
Is there a way to implement this scenario in current version (v0.1.6) of logly?
Or can it be considered as a reasonable feature request?
Context
Suppose I have a bunch of async tasks to run:
tasks = [ myfunc("task1"), myfunc("task2"), ...]I'm looking for a way to configure logly logger so that:
log messages from each task are written to corresponding file (separate sinks):
sink1 =>
logs/task1.log, sink2 =>logs/task2.log, ...with each file individually rotated, having independant log levels, etc.
log messages from these tasks don't go to any other sink configured in application
Using
bindandfllter_functionis not enough to implement such behaviour, because log messages are still propagated to other configured sinks andfilter_functiondoes not treat logs from instances of myfunc separately.It is possible in python standard
loggingand inloguru(not trivial though).Code Example
Logly Version
0.1.6
Python Version
3.10.12
Operating System
Ububtu 22.04
Additional Information
No response
Solution Interest
I just need help/guidance
Question Type
How-to questions
Specific Questions
No response
Checklist