import pygogo as gogo
formatter = gogo.formatters.structured_formatter
logger = gogo.Gogo('struct', low_formatter=formatter).get_logger(foo="barbar")
logger.debug('bought', extra={"type": "apple", "price": 250, "color": "red"})
#=> {"name": "struct.base", "level": "DEBUG", "color": "red", "price": 250, "msecs": 587.5449180603027, "time": "2016-01-25 16:02:24", "message": "bought", "foo": "barbar", "type": "apple"}
logger.debug('bought', extra={"type": "PC", "price": 100000, "memory": "16GB"})
#=>{"name": "struct.base", "level": "DEBUG", "price": 100000, "memory": "16GB", "msecs": 587.9619121551514, "time": "2016-01-25 16:02:24", "message": "bought", "foo": "barbar", "type": "PC"}
Es scheint, dass Sie die Ausgabe steuern können, indem Sie "low_level" als Argument des Konstruktors übergeben.
import pygogo as gogo
formatter = gogo.formatters.structured_formatter
logger = gogo.Gogo('struct', low_formatter=formatter, low_level='info').get_logger(foo="barbar")
logger.debug('bought', extra={"type": "apple", "price": 250, "color": "red"})
#=>Erscheint nicht
logger.info('bought', extra={"type": "PC", "price": 100000, "memory": "16GB"})
#=>Geh raus
Recommended Posts