#NEWLINE# def start_logging( out = _stdout , level = 'info' ) : #NEWLINE# #INDENT# '\n    Begin logging.\n\n    :param out: if provided, a file-like object to log to. By default, this is\n                stdout.\n    :param level: the maximum log-level to emit (a string)\n    ' #NEWLINE# global _log_level , _loggers , _started_logging #NEWLINE# if ( level not in log_levels ) : #NEWLINE# #INDENT# raise RuntimeError ( "Invalid log level '{0}'; valid are: {1}" . format ( level , ', ' . join ( log_levels ) ) ) #NEWLINE# #UNINDENT# if _started_logging : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# _started_logging = True #NEWLINE# _log_level = level #NEWLINE# handler = _TxaioFileHandler ( out ) #NEWLINE# logging . getLogger ( ) . addHandler ( handler ) #NEWLINE# logging . raiseExceptions = True #NEWLINE# level_to_stdlib = { #NEWLINE# #INDENT# 'critical' : logging . CRITICAL , #NEWLINE# 'error' : logging . ERROR , #NEWLINE# 'warn' : logging . WARNING , #NEWLINE# 'info' : logging . INFO , #NEWLINE# 'debug' : logging . DEBUG , #NEWLINE# 'trace' : logging . DEBUG , #NEWLINE# #UNINDENT# } #NEWLINE# logging . getLogger ( ) . setLevel ( level_to_stdlib [ level ] ) #NEWLINE# for logger in _loggers : #NEWLINE# #INDENT# logger . _set_log_level ( level )