The following code is part of implementation of T80072: Create python API for CLOG.
You can execute the following code, but:
- log message, path is not copied, so expect memory violation
- everything is logged to one logger
import bpy # in design it is _bpy bpy.utils.log.error("err hello") bpy.utils.log.warning("warn hello") bpy.utils.log.info("info hello") bpy.utils.log.debug("debug hello") # ---- import logging import bpy log = logging.getLogger("bpy.my_addon") # add type for easy filtering in blender log.addHandler(bpy.utils.log.LogHandler()) log.setLevel(logging.INFO) # default is WARNING # ---- import bpy import logging log = bpy.utils.log.getLogger("bpy.my_addon") # automatically add handler (can also set log level based on blener's log level) log.setLevel(logging.INFO)