Skip to content

Tag: logging

Python Multiprocessing Logging via QueueHandler

I have a Python multiprocessing application to which I would like to add some logging functionality. The Python logging cookbook recommends using a Queue. Every process will put log records into it via the QueueHandler and a Listener Process will handle the records via a predefined Handler. Here is the exampl…

Logging with Python, ROS, and C++

I have a codebase of Python and C++ code, including heavy use of ROS. Logging is done throughout the Python code with both system logger and rospy logging — contrived example: As for C++ code we need to add logging, probably with glog but I’m open to other options. Is there a way to integrate the …

How to use logging.getLogger(__name__) in multiple modules

From the logging howto for Python 2.7 (my emphasis): A good convention to use when naming loggers is to use a module-level logger, in each module which uses logging, named as follows: logger = logging.getLogger(__name__) This means that logger names track the package/module hierarchy, and it’s intuitively obv…

Python logging into file as a dictionary or JSON

I am trying to set up logging where I can log in both stdout and on to a file. This i have accomplished using the following code: The output of this something like this: What I am trying to accomplish is logging this output to a file not as it is printing to stdout, but as a dictionary or JSON