<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import sys <EOL> import traceback <EOL> import threading <EOL> NAME = '<STR_LIT>' <EOL> g_lock = threading . Lock ( ) <EOL> DEBUG = False <EOL> if DEBUG : <EOL> try : <EOL> import ctypes <EOL> OutputDebugStringW = ctypes . windll . kernel32 . OutputDebugStringW <EOL> OutputDebugStringW . argtypes = [ ctypes . c_wchar_p ] <EOL> except : <EOL> DEBUG = False <EOL> def write_log ( level , fmtstr , * args ) : <EOL> s = NAME + '<STR_LIT>' + level + '<STR_LIT>' + ( fmtstr % args ) <EOL> if DEBUG : <EOL> OutputDebugStringW ( s ) <EOL> with g_lock : <EOL> print ( s ) <EOL> def info ( fmtstr , * args ) : <EOL> write_log ( '<STR_LIT>' , fmtstr , * args ) <EOL> def warning ( fmtstr , * args ) : <EOL> write_log ( '<STR_LIT>' , fmtstr , * args ) <EOL> def error ( fmtstr , * args ) : <EOL> write_log ( '<STR_LIT>' , fmtstr , * args ) <EOL> def exception ( fmtstr , * args ) : <EOL> exc_type , exc_value , exc_traceback = sys . exc_info ( ) <EOL> exception_message = traceback . format_exception ( exc_type , exc_value , exc_traceback ) <EOL> write_log ( '<STR_LIT>' , fmtstr , * args ) <EOL> with g_lock : <EOL> print ( '<STR_LIT>' . join ( [ '<STR_LIT:U+0020>' + line for line in exception_message ] ) ) </s>
