By FrUh


2013-08-17 19:21:30 8 Comments

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.

2 comments

@Martijn Pieters 2013-08-17 19:23:26

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().

@FrUh 2013-08-17 19:39:30

thank you very much, I was using it in my previuos project and I was wondering why it doesn't work. AND I DID NOT NOTICE the LOWER CASE. Ah.

@Martijn Pieters 2013-08-17 19:57:39

And you did not notice the CAPS LOCK either, by the looks of it. :-P (And sorry, you can only mark one answer as accepted, thanks for the brief acceptance though!)

@karthikr 2013-08-17 19:23:36

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")

@FrUh 2013-08-17 19:38:14

thank you very much, I was using it in my previuos project and I was wondering why it doesn't work. AND I DID NOT NOTICE the LOWER CASE. Ah.

Related Questions

Sponsored Content

59 Answered Questions

[SOLVED] Calling an external command in Python

33 Answered Questions

[SOLVED] How to get the current time in Python

  • 2009-01-06 04:54:23
  • user46646
  • 2893014 View
  • 2496 Score
  • 33 Answer
  • Tags:   python datetime time

21 Answered Questions

[SOLVED] Does Python have a ternary conditional operator?

25 Answered Questions

[SOLVED] How can I safely create a nested directory?

28 Answered Questions

[SOLVED] Finding the index of an item given a list containing it in Python

  • 2008-10-07 01:39:38
  • Eugene M
  • 3363623 View
  • 2777 Score
  • 28 Answer
  • Tags:   python list indexing

16 Answered Questions

[SOLVED] What are metaclasses in Python?

12 Answered Questions

[SOLVED] How can I make a time delay in Python?

16 Answered Questions

[SOLVED] String formatting: % vs. .format

20 Answered Questions

10 Answered Questions

[SOLVED] Does Python have a string 'contains' substring method?

Sponsored Content