def __init__(self, logger='cvprac', syslog=False, filename=None,
log_level='INFO'):
''' Initialize the client and configure logging. Either syslog, file
logging, both, or none can be enabled. If neither syslog
nor filename is specified then no logging will be performed.
Args:
logger (str): The name assigned to the logger.
syslog (bool): If True enable logging to syslog. Default is
False.
filename (str): Log to the file specified by filename. Default
is None.
log_level (str): Log level to use for logger. Default is INFO.
'''
self.authdata = None
self.cert = False
self.connect_timeout = None
self.cookies = None
self.error_msg = ''
self.node_cnt = None
self.node_pool = None
self.nodes = None
self.port = None
self.protocol = None
self.session = None
self.url_prefix = None
self._last_used_node = None
# Save proper headers
self.headers = {'Accept': 'application/json',
'Content-Type': 'application/json'}
self.log = logging.getLogger(logger)
self.set_log_level(log_level)
if syslog:
# Enables sending logging messages to the local syslog server.
self.log.addHandler(SysLogHandler())
if filename:
# Enables sending logging messages to a file.
self.log.addHandler(logging.FileHandler(filename))
if syslog is False and filename is None:
# Not logging so use the null handler
self.log.addHandler(logging.NullHandler())
# Instantiate the CvpApi class
self.api = CvpApi(self)
评论列表
文章目录