Dear Hans,

i haven't worked with the logging module yet but as a guess from what you write 
in your message:

according to the documentation the format statement for lineno should be 
%(lineno)d, but you use %(lineno)s.

Best regards,

Ralf

> Hi,
> 
> I have some trouble with the logging module.
> 
> When I run this program with python2.3:
> 
> #------------
> import logging,sys
> formatter = logging.Formatter('%(name)s :%(asctime)s %(filename)s
> %(lineno)s %(levelname)s  %(message)s')
> stdout_handler = logging.StreamHandler(sys.stdout)
> stdout_handler.setFormatter(formatter)
> logger=logging.getLogger('')
> logger.addHandler(stdout_handler)
> logger.setLevel(logging.DEBUG)
> logging.debug('A debug message')
> logging.info('Some information')
> logging.warning('A shot across the bows')
> #------------
> 
> I get the following output:
> 
> root :2006-08-31 20:20:15,085 __init__.py 988 DEBUG  A debug message
> root :2006-08-31 20:20:15,085 __init__.py 988 INFO  Some information
> root :2006-08-31 20:20:15,085 __init__.py 988 WARNING  A shot across thebows
> 
> Note that the line number always appears as 988. I'd like it to be the
> line number where the logging command has been executed. The documentation
> says that %(lineno)d should work 'if available'.
> 
> Is this generally not available? Can I make it available? If so, how?
> 
> Any advice welcome.
> 
> Many thanks in advance,
> 
> Hans
> 

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to