def new_instance(cls, log_type=None, settings=None): if settings["class"]: if settings["class"].startswith("logging.handlers."): from mo_logs.log_usingThread import StructuredLogger_usingThread from mo_logs.log_usingHandler import StructuredLogger_usingHandler return StructuredLogger_usingThread( StructuredLogger_usingHandler(settings)) else: with suppress_exception: from mo_logs.log_usingLogger import make_log_from_settings return make_log_from_settings(settings) # OH WELL :( if log_type == "logger": from mo_logs.log_usingLogger import StructuredLogger_usingLogger return StructuredLogger_usingLogger(settings) if log_type == "file" or settings.file: return StructuredLogger_usingFile(settings.file) if log_type == "file" or settings.filename: return StructuredLogger_usingFile(settings.filename) if log_type == "console": from mo_logs.log_usingThread import StructuredLogger_usingThread return StructuredLogger_usingThread( StructuredLogger_usingStream(STDOUT)) if log_type == "mozlog": from mo_logs.log_usingMozLog import StructuredLogger_usingMozLog return StructuredLogger_usingMozLog( STDOUT, coalesce(settings.app_name, settings.appname)) if log_type == "stream" or settings.stream: from mo_logs.log_usingThread import StructuredLogger_usingThread return StructuredLogger_usingThread( StructuredLogger_usingStream(settings.stream)) if log_type == "elasticsearch" or settings.stream: from mo_logs.log_usingElasticSearch import ( StructuredLogger_usingElasticSearch, ) return StructuredLogger_usingElasticSearch(settings) if log_type == "email": from mo_logs.log_usingEmail import StructuredLogger_usingEmail return StructuredLogger_usingEmail(settings) if log_type == "ses": from mo_logs.log_usingSES import StructuredLogger_usingSES return StructuredLogger_usingSES(settings) if log_type.lower() in ["nothing", "none", "null"]: from mo_logs.log_usingNothing import StructuredLogger return StructuredLogger() Log.error("Log type of {{config|json}} is not recognized", config=settings)
def new_instance(cls, settings): settings = wrap(settings) if settings["class"]: if settings["class"].startswith("logging.handlers."): from mo_logs.log_usingLogger import StructuredLogger_usingLogger return StructuredLogger_usingLogger(settings) else: with suppress_exception: from mo_logs.log_usingLogger import make_log_from_settings return make_log_from_settings(settings) # OH WELL :( if settings.log_type == "file" or settings.file: return StructuredLogger_usingFile(settings.file) if settings.log_type == "file" or settings.filename: return StructuredLogger_usingFile(settings.filename) if settings.log_type == "console": from mo_logs.log_usingThreadedStream import StructuredLogger_usingThreadedStream return StructuredLogger_usingThreadedStream(STDOUT) if settings.log_type == "mozlog": from mo_logs.log_usingMozLog import StructuredLogger_usingMozLog return StructuredLogger_usingMozLog(STDOUT, coalesce(settings.app_name, settings.appname)) if settings.log_type == "stream" or settings.stream: from mo_logs.log_usingThreadedStream import StructuredLogger_usingThreadedStream return StructuredLogger_usingThreadedStream(settings.stream) if settings.log_type == "elasticsearch" or settings.stream: from mo_logs.log_usingElasticSearch import StructuredLogger_usingElasticSearch return StructuredLogger_usingElasticSearch(settings) if settings.log_type == "email": from mo_logs.log_usingEmail import StructuredLogger_usingEmail return StructuredLogger_usingEmail(settings) if settings.log_type == "ses": from mo_logs.log_usingSES import StructuredLogger_usingSES return StructuredLogger_usingSES(settings) if settings.log_type.lower() in ["nothing", "none", "null"]: from mo_logs.log_usingNothing import StructuredLogger return StructuredLogger() Log.error("Log type of {{log_type|quote}} is not recognized", log_type=settings.log_type)
def new_instance(cls, settings): settings = wrap(settings) if settings["class"]: if settings["class"].startswith("logging.handlers."): from mo_logs.log_usingLogger import StructuredLogger_usingLogger return StructuredLogger_usingLogger(settings) else: with suppress_exception: from mo_logs.log_usingLogger import make_log_from_settings return make_log_from_settings(settings) # OH WELL :( if settings.log_type == "file" or settings.file: return StructuredLogger_usingFile(settings.file) if settings.log_type == "file" or settings.filename: return StructuredLogger_usingFile(settings.filename) if settings.log_type == "console": from mo_logs.log_usingThreadedStream import StructuredLogger_usingThreadedStream return StructuredLogger_usingThreadedStream(sys.stdout) if settings.log_type == "stream" or settings.stream: from mo_logs.log_usingThreadedStream import StructuredLogger_usingThreadedStream return StructuredLogger_usingThreadedStream(settings.stream) if settings.log_type == "elasticsearch" or settings.stream: from mo_logs.log_usingElasticSearch import StructuredLogger_usingElasticSearch return StructuredLogger_usingElasticSearch(settings) if settings.log_type == "email": from mo_logs.log_usingEmail import StructuredLogger_usingEmail return StructuredLogger_usingEmail(settings) if settings.log_type == "ses": from mo_logs.log_usingSES import StructuredLogger_usingSES return StructuredLogger_usingSES(settings) if settings.log_type.lower() in ["nothing", "none", "null"]: from mo_logs.log_usingNothing import StructuredLogger return StructuredLogger() Log.error("Log type of {{log_type|quote}} is not recognized", log_type=settings.log_type)