<s> __author__ = '<STR_LIT>' <EOL> import socket <EOL> import logging <EOL> from logging import handlers <EOL> import logsna <EOL> LOG_UNIX_SOCKET = '<STR_LIT>' <EOL> class LogUnixSocketHandler ( handlers . SocketHandler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , host = LOG_UNIX_SOCKET ) : <EOL> """<STR_LIT>""" <EOL> handlers . SocketHandler . __init__ ( self , host , None ) <EOL> def makeSocket ( self , timeout = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> s = socket . socket ( socket . AF_UNIX , socket . SOCK_STREAM ) <EOL> if hasattr ( s , '<STR_LIT>' ) : <EOL> s . settimeout ( timeout ) <EOL> s . connect ( self . host ) <EOL> return s <EOL> def get_stream_logger ( name , level = logging . DEBUG ) : <EOL> """<STR_LIT>""" <EOL> logger = logging . getLogger ( name ) <EOL> logger . setLevel ( level ) <EOL> socket_handler = LogUnixSocketHandler ( ) <EOL> logger . addHandler ( socket_handler ) <EOL> return logger <EOL> def get_console_logger ( name ) : <EOL> logger = logging . getLogger ( name ) <EOL> logger . setLevel ( logging . DEBUG ) <EOL> ch = logging . StreamHandler ( ) <EOL> ch . setLevel ( logging . DEBUG ) <EOL> formatter = logsna . Formatter ( ) <EOL> ch . setFormatter ( formatter ) <EOL> logger . addHandler ( ch ) <EOL> return logger </s>
