def init_logging(name, level=logging.INFO):
logger = logging.getLogger(name)<EOL>logger.setLevel(level)<EOL>try:<EOL><INDENT>if os.isatty(sys.stdout.fileno()) andnot sys.platform.startswith('<STR_LIT>'):<EOL><INDENT>formatter = ColoredFormatter()<EOL><DEDENT>elif level == logging.DEBUG:<EOL><INDENT>formatter = Formatter('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>formatter = Formatter('<STR_LIT>')<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>formatter = Formatter('<STR_LIT>')<EOL><DEDENT>handler = logging.StreamHandler()<EOL>handler.setFormatter(formatter)<EOL>logger.addHandler(handler)<EOL>
Logging config

    Set the level and create a more detailed formatter for debug mode.