Question

Could you please help me, whats wrong.

import logging

if (__name__ == "__main__"):
    logging.basicConfig(format='[%(asctime)s] %(levelname)s::%(module)s::%(funcName)s() %(message)s', level=logging.DEBUG)
    logging.INFO("test")

And I can't run it, I've got an error:

Traceback (most recent call last):
  File "/home/htfuws/Programming/Python/just-kidding/main.py", line 5, in 
    logging.INFO("test")
TypeError: 'int' object is not callable

Thank you very much.

Was it helpful?

Solution

logging.INFO denotes an integer constant with value of 20

INFO Confirmation that things are working as expected.

What you need is logging.info

logging.info("test")

OTHER TIPS

You are trying to call logging.INFO, which is an integer constant denoting one of the pre-defined logging levels:

>>> import logging
>>> logging.INFO
20
>>> type(logging.INFO)
<type 'int'>

You probably wanted to use the logging.info() function (note, all lowercase) instead:

Logs a message with level INFO on this logger. The arguments are interpreted as for debug().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top