def log(self, msg, level="<STR_LIT:info>"):
if not self.config.get("<STR_LIT>"):<EOL><INDENT>level = LOG_LEVELS.get(level, level)<EOL>syslog(level, u"<STR_LIT:{}>".format(msg))<EOL><DEDENT>else:<EOL><INDENT>with open(self.config["<STR_LIT>"], "<STR_LIT>") as f:<EOL><INDENT>log_time = time.strftime("<STR_LIT>")<EOL>if isinstance(msg, (dict, list, set, tuple)):<EOL><INDENT>msg = pformat(msg)<EOL>if "<STR_LIT:\n>" in msg:<EOL><INDENT>msg = u"<STR_LIT:\n>" + msg<EOL><DEDENT><DEDENT>out = u"<STR_LIT>".format(log_time, level.upper(), msg)<EOL>try:<EOL><INDENT>f.write(out.encode("<STR_LIT:utf-8>"))<EOL><DEDENT>except (AttributeError, UnicodeDecodeError):<EOL><INDENT>f.write(out)<EOL><DEDENT><DEDENT><DEDENT>
log this information to syslog or user provided logfile.