<s> """<STR_LIT>""" <EOL> import logging <EOL> import logging . config <EOL> import logging . handlers <EOL> import os <EOL> from smoker . logger . level_handler import LevelHandler <EOL> lg = None <EOL> def disable_console_logging ( logger ) : <EOL> handlers = logger . handlers <EOL> for handler in handlers : <EOL> if isinstance ( handler , logging . StreamHandler ) : <EOL> logger . removeHandler ( handler ) <EOL> if logger . parent : <EOL> disable_console_logging ( logger . parent ) <EOL> def init ( name = '<STR_LIT>' , level = logging . WARN , syslog = True , console = True , <EOL> config_file = '<STR_LIT>' ) : <EOL> global lg <EOL> if os . path . exists ( config_file ) : <EOL> logging . config . fileConfig ( config_file , disable_existing_loggers = False ) <EOL> lg = logging . getLogger ( name ) <EOL> lg . setLevel ( level ) <EOL> if os . path . exists ( config_file ) : <EOL> if not console : <EOL> disable_console_logging ( lg ) <EOL> return lg <EOL> if console : <EOL> lg_console = LevelHandler ( ) <EOL> lg_console . setFormatter ( <EOL> logging . Formatter ( '<STR_LIT>' ) ) <EOL> lg . addHandler ( lg_console ) <EOL> if syslog : <EOL> lg_syslog = logging . handlers . SysLogHandler ( address = '<STR_LIT>' ) <EOL> lg_syslog . setFormatter ( <EOL> logging . Formatter ( '<STR_LIT>' ) ) <EOL> lg . addHandler ( lg_syslog ) <EOL> return lg </s>
