kibt...@gmail.com wrote: > I wanted to write/extend the logging library to have a custom Error number > for each exception (error) the code has. What's the best approach for > this? If possible can someone please provide a good starting code snippet. > Thanks
You can pass arbitrary data via the `extra` parameter: $ cat log_errno.py import logging logger = logging.getLogger() logging.basicConfig(format="ERROR #%(errno)s: %(message)s") logger.error("First", extra=dict(errno=42)) logger.error("Second", extra=dict(errno=123)) $ python3 log_errno.py ERROR #42: First ERROR #123: Second If that's not you want you have to invest more time into a better description of your goal, with example code and output. -- https://mail.python.org/mailman/listinfo/python-list