U ``i @sJddlmZddlZddlZddZGdddejZdedfdd ZdS) )print_functionNcCst|S)z$Formatter for unserialisable values.)str)objrk/Volumes/workspace/Demo/src/IotBifrostDemoAssets/src/iot_sitewise_asset_model_lambda/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<zt |d|d<Wnt t fk rYnX|j r|j s||j |_ |j r|j |d<tj||jd}t|dr|d }|S) Nasctimecsi|]\}}|r||qSrr).0kvZ record_dictrr "sz(JsonFormatter.format..msgmessage exception)defaultdecodezutf-8)__dict__copy formatTimeritems isinstancedict getMessagejsonloads TypeError ValueErrorexc_infoexc_textformatExceptiondumpsrhasattrr )rrecordZlog_dictZ json_recordrrrformats*      zJsonFormatter.format)__name__ __module__ __qualname____doc__r r2 __classcell__rrrrr s rDEBUGcKsz|r"tjjD]}||f|q tj||s6|}td|td|td|td|dS)NZbotoboto3botocoreurllib3)loggingroothandlers setFormattersetLevel getLogger)r formatter_cls boto_levelrhandlerrrrsetupFs  rE) __future__rr(r<r FormatterrrErrrrs ;