On 24 Apr 2020 22:18:45 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:

> DL Neil <pythonl...@danceswithmice.info> writes:
> >Python's logging library enables messages to be formatted
> >accordingly, and directed differently, depending upon 'level of
> >severity'. So, as well as the flexibility mentioned before, there is
> >an option to direct logging output to stdout/stderr as a
> >matter-of-course!  
> 
>   Here's some example code I wrote:
> 
> import logging
> 
> def setup_logging( logging ):
>     """Setup a logger using the standard logging module,
>     which needs to be passed as the argument"""
>     logger = logging.getLogger()
>     handler = logging.StreamHandler()
>     formatter = logging.Formatter( '%(asctime)s %(name)-12s
> %(levelname)-8s %(message)s' ) handler.setFormatter( formatter )
>     logger.addHandler( handler )
>     logger.setLevel( logging.DEBUG )
>     return logger
> 
> logger = setup_logging( logging )
> logger.debug( "Hi!" )
> 
>   It outputs (apparently to sys.stderr):
> 
> 2020-04-24 23:13:59,467 root         DEBUG    Hi!
> 
> 

Yes, I know about this. But in this particular case I don't gain much
by using a logger. print() is good enough.

I will investigate yielding and callback to see which is best in my
particular case.




-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to