B {Dai @sJddlmZddlZddlZddZGdddejZdedfdd ZdS) )print_functionNcCst|S)z$Formatter for unserialisable values.)str)objr:/tmp/pip-target-ffaknybf/lib/python/crhelper/log_helper.py_json_formattersrcs(eZdZdZfddZddZZS) JsonFormatterzAWS Lambda Logging formatter. Formats the log message as a JSON encoded string. If the message is a dict it will be used directly. If the message can be parsed as JSON, then the parse d value is used in the output record. c s:tt|dddd|_|j||dt|_dS)Nz %(asctime)sz %(levelname)sz %(name)s.%(funcName)s:%(lineno)d) timestamplevellocationZ json_default)superr__init__ format_dictupdatepoprdefault_json_formatter)selfkwargs) __class__rrr s  zJsonFormatter.__init__c s|j||d<fdd|jD}tdtrLd|d<n<||d<yt |d|d<Wnt t fk rYnX|j r|j s||j |_ |j r|j |d<tj||jd}t|dr|d }|S) Nasctimecsi|]\}}|r||qSrr).0kv) record_dictrr "sz(JsonFormatter.format..msgmessage exception)defaultdecodezutf-8)__dict__copy formatTimeritems isinstancedict getMessagejsonloads TypeError ValueErrorexc_infoexc_textformatExceptiondumpsrhasattrr)rrecordZlog_dictZ json_recordr)rrformats(      zJsonFormatter.format)__name__ __module__ __qualname____doc__r r1 __classcell__rr)rrr s rDEBUGcKs~|r&x tjjD]}||f|qWtj||s:|}td|td|td|td|dS)NZbotoZboto3Zbotocoreurllib3)loggingroothandlers setFormattersetLevel getLogger)r Z formatter_clsZ boto_levelrhandlerrrrsetupFs r@) __future__rr'r9r Formatterrr@rrrrs ;