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"}
It seems that output control can be done by passing low_level
as an argument of the constructor.
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"})
#=>Does not appear
logger.info('bought', extra={"type": "PC", "price": 100000, "memory": "16GB"})
#=>Get out
Recommended Posts