<s> """<STR_LIT>""" <EOL> from __future__ import ( <EOL> absolute_import , division , print_function , with_statement , <EOL> unicode_literals ) <EOL> import sys <EOL> import logging <EOL> import socket <EOL> from os import environ <EOL> from logging import handlers as hdlrs <EOL> from builtins import * <EOL> ENCODING = '<STR_LIT:utf-8>' <EOL> module_hdlr = logging . StreamHandler ( sys . stdout ) <EOL> module_logger = logging . getLogger ( __name__ ) <EOL> module_logger . addHandler ( module_hdlr ) <EOL> def stdout_hdlr ( ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return logging . StreamHandler ( sys . stdout ) <EOL> def stderr_hdlr ( ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return logging . StreamHandler ( sys . stderr ) <EOL> def fileobj_hdlr ( f , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return logging . StreamHandler ( f ) <EOL> def file_hdlr ( filename , mode = '<STR_LIT:a>' , encoding = ENCODING , delay = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> fkwargs = { '<STR_LIT>' : mode , '<STR_LIT>' : encoding , '<STR_LIT>' : delay } <EOL> return logging . FileHandler ( filename , ** fkwargs ) <EOL> def socket_hdlr ( host = '<STR_LIT:localhost>' , port = None , tcp = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if tcp : <EOL> def_port = logging . handlers . DEFAULT_TCP_LOGGING_PORT <EOL> handler = hdlrs . SocketHandler <EOL> else : <EOL> def_port = logging . handlers . DEFAULT_UDP_LOGGING_PORT <EOL> handler = hdlrs . DatagramHandler <EOL> address = ( host , port or def_port ) <EOL> return handler ( * address ) <EOL> def syslog_hdlr ( host = '<STR_LIT:localhost>' , port = None , tcp = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if tcp : <EOL> def_port = logging . handlers . SYSLOG_TCP_PORT <EOL> socktype = socket . SOCK_STREAM <EOL> else : <EOL> def_port = logging . handlers . SYSLOG_UDP_PORT <EOL> socktype = socket . SOCK_DGRAM <EOL> address = ( host , port or def_port ) <EOL> return hdlrs . SysLogHandler ( address , socktype = socktype ) <EOL> def buffered_hdlr ( target = None , capacity = <NUM_LIT> , level = '<STR_LIT:error>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> target = target or logging . StreamHandler ( sys . stdout ) <EOL> return hdlrs . MemoryHandler ( capacity , level . upper ( ) , target ) <EOL> def webhook_hdlr ( url , host = '<STR_LIT:localhost>' , port = None , get = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> method = '<STR_LIT:GET>' if get else '<STR_LIT:POST>' <EOL> host = '<STR_LIT>' % ( host , port ) if port else host <EOL> return hdlrs . HTTPHandler ( host , url , method = method ) <EOL> def email_hdlr ( subject = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> host = kwargs . get ( '<STR_LIT:host>' , '<STR_LIT:localhost>' ) <EOL> port = kwargs . get ( '<STR_LIT:port>' ) <EOL> address = ( host , port ) if port else host <EOL> sender = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' % environ . get ( '<STR_LIT>' ) ) <EOL> def_recipient = '<STR_LIT>' % environ . get ( '<STR_LIT>' ) <EOL> recipients = kwargs . get ( '<STR_LIT>' , [ def_recipient ] ) <EOL> subject = kwargs . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> username = kwargs . get ( '<STR_LIT:username>' ) <EOL> password = kwargs . get ( '<STR_LIT:password>' ) <EOL> args = ( address , sender , recipients , subject ) <EOL> credentials = ( username , password ) if username or password else None <EOL> return hdlrs . SMTPHandler ( * args , credentials = credentials ) </s>
