T
Torsten Bronger
Hallöchen!
Is there a portable and simply way to direct file-like IO to simply
nothing? I try to implement some sort of NullLogging by saying
--8<---------------cut here---------------start------------->8---
import logging
if options.logging:
logging.basicConfig(level=logging.DEBUG, filename=options.logfile, filemode="w",
format='%(asctime)s %(name)s %(levelname)s %(message)s')
else:
# redirect logging to a memory buffer in order to simply ignore it.
import StringIO
logging.basicConfig(stream=StringIO.StringIO())
--8<---------------cut here---------------end--------------->8---
However, this consumes memory. Is there a better way?
Tschö,
Torsten.
Is there a portable and simply way to direct file-like IO to simply
nothing? I try to implement some sort of NullLogging by saying
--8<---------------cut here---------------start------------->8---
import logging
if options.logging:
logging.basicConfig(level=logging.DEBUG, filename=options.logfile, filemode="w",
format='%(asctime)s %(name)s %(levelname)s %(message)s')
else:
# redirect logging to a memory buffer in order to simply ignore it.
import StringIO
logging.basicConfig(stream=StringIO.StringIO())
--8<---------------cut here---------------end--------------->8---
However, this consumes memory. Is there a better way?
Tschö,
Torsten.