0

With the logging module of python3 I am logging to a file like this:

import logging
logging.basicConfig(filename='log')
logging.info('123')

Now everytime a logging event occurs, i want a function to be called as well with the LogRecord as an argument.

How do I achieve this?

0

1 Answer 1

1

You could create a logging.Filter object that reviews the LogRecord and decides whether or not it should be logged. In this code you could also perform other logic: https://docs.python.org/3/library/logging.html#filter-objects.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.