An alternative logger object. If no logger is given logdecorator creates a logger object with the name of the module the decorated function is in (decorated_function.__module__) Default: Creates a new logger with the name decorated_function.__module__
I find that the auto-created logger with the name of the decorated function is very useful. It might help to be able to specify a handler for this auto-created logger, e.g.
# app.py
import logging
logging.basicConfig(level=logging.INFO)
# Set up pyzmq log handler
from zmq.log.handlers import PUBHandler
ctx = zmq.Context.instance()
publisher = ctx.socket(zmq.PUB)
publisher.bind('ipc://log')
zmq_log_handler = PUBHandler(publisher)
# Set up logdecorator
from logdecorator import log_on_start
@log_on_start(logging.INFO, "Starting greeter", handler=zmq_log_handler)
def greeter():
print("Hello world")
greeter()
Then, on a separate process, I would first run the following to listen for a log event:
$ python -m zmq.log ipc://log
Again, on a separate process, I run the main script:
From https://github.com/sighalt/logdecorator#documentation
I find that the auto-created logger with the name of the decorated function is very useful. It might help to be able to specify a handler for this auto-created logger, e.g.
Then, on a separate process, I would first run the following to listen for a log event:
Again, on a separate process, I run the main script:
References