sdss / lvmcam

An actor implementation of sdss-araviscam for lvmagp
https://sdss-lvmcam.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Logging #52

Closed wasndas closed 2 years ago

wasndas commented 2 years ago

Code example:

import logging
from clu import AMQPClient
from sdsstools.logger import StreamFormatter   

amqpc = AMQPClient(name="hello") # works also for AMQPActor
amqpc.log.sh.formatter = StreamFormatter(fmt='%(asctime)s %(name)s %(levelname)s %(filename)s:%(lineno)d: \033[1m%(message)s\033[21m') 
amqpc.log.sh.setLevel(logging.DEBUG)

logger = amqpc.log

logger.debug('This is a message!')
logger.info('This is a message!')
logger.warning('This is a message!')
logger.error('This is a message!')
logger.critical('This is a message!')
amqp=AMQPActor(name="test")
assert(amqp.log.name == 'clu:test')
logger = get_logger("clu:test")

*If you wanna use the logger inside the commands section, you can retrieve the actor logger from command: Command. logger = command.actor.log