本文整理汇总了Python中util.get_logger函数的典型用法代码示例。如果您正苦于以下问题:Python get_logger函数的具体用法?Python get_logger怎么用?Python get_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_logger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
super(Gauge, self).__init__(*args, **kwargs)
sysprefix = get_sys_prefix()
self.config_file = os.getenv(
'GAUGE_CONFIG', sysprefix + '/etc/ryu/faucet/gauge.yaml')
self.exc_logfile = os.getenv(
'GAUGE_EXCEPTION_LOG',
sysprefix + '/var/log/ryu/faucet/gauge_exception.log')
self.logfile = os.getenv(
'GAUGE_LOG', sysprefix + '/var/log/ryu/faucet/gauge.log')
# Setup logging
self.logger = get_logger(
self.logname, self.logfile, logging.DEBUG, 0)
# Set up separate logging for exceptions
self.exc_logger = get_logger(
self.exc_logname, self.exc_logfile, logging.CRITICAL, 1)
# Set the signal handler for reloading config file
signal.signal(signal.SIGHUP, self.signal_handler)
# dict of watchers/handlers:
# indexed by dp_id and then by name
self.watchers = {}
confs = watcher_parser(self.config_file, self.logname)
for conf in confs:
watcher = watcher_factory(conf)(conf, self.logname)
self.watchers.setdefault(watcher.dp.dp_id, {})
self.watchers[watcher.dp.dp_id][watcher.conf.type] = watcher
# Create dpset object for querying Ryu's DPSet application
self.dpset = kwargs['dpset']
示例2: run
def run(self):
if __debug__:
logging_info = {
'mod': 'ReceiveFirstPhaseCommitMessageAction',
'endpoint_string': self.local_endpoint._endpoint_uuid_str
}
log_msg = 'Start receive first phase commit message ' + str(self.event_uuid)
util.get_logger().info(log_msg,extra=logging_info)
act_event = self.local_endpoint._act_event_map.get_event(
self.event_uuid)
if act_event != None:
if self.successful:
act_event.receive_successful_first_phase_commit_msg(
self.event_uuid,self.msg_originator_endpoint_uuid,
self.children_event_endpoint_uuids)
else:
act_event.receive_unsuccessful_first_phase_commit_msg(
self.event_uuid,self.msg_originator_endpoint_uuid)
if __debug__:
log_msg = 'End receive first phase commit message ' + str(self.event_uuid)
util.get_logger().info(log_msg,extra=logging_info)
示例3: service
def service(self):
if __debug__:
logging_info = {
'mod': 'ReceiveRequestBackoutAction',
'endpoint_string': self.local_endpoint._endpoint_uuid_str
}
log_msg = 'Start receive request backout action ' + str(self.uuid)
util.get_logger().info(log_msg,extra=logging_info)
evt = self.local_endpoint._act_event_map.get_and_remove_event(
self.uuid)
if evt == None:
# could happen for instance if there are loops in endpoint
# call graph. In this case, might get more than one
# request to backout an event. However, the first backout
# has already removed the the active event from the active
# event map.
return
skip_partner = False
if self.requesting_endpoint == util.PARTNER_ENDPOINT_SENTINEL:
skip_partner = True
# FIXME: should probably be in a separate thread
evt.forward_backout_request_and_backout_self(skip_partner)
if __debug__:
log_msg = 'End receive request backout action ' + evt.str_uuid
util.get_logger().info(log_msg,extra=logging_info)
示例4: __init__
def __init__(self, *args, **kwargs):
super(Faucet, self).__init__(*args, **kwargs)
# There doesnt seem to be a sensible method of getting command line
# options into ryu apps. Instead I am using the environment variable
# FAUCET_CONFIG to allow this to be set, if it is not set it will
# default to valve.yaml
sysprefix = get_sys_prefix()
self.config_file = os.getenv(
'FAUCET_CONFIG', sysprefix + '/etc/ryu/faucet/faucet.yaml')
self.logfile = os.getenv(
'FAUCET_LOG', sysprefix + '/var/log/ryu/faucet/faucet.log')
self.exc_logfile = os.getenv(
'FAUCET_EXCEPTION_LOG',
sysprefix + '/var/log/ryu/faucet/faucet_exception.log')
# Set the signal handler for reloading config file
signal.signal(signal.SIGHUP, self.signal_handler)
# Create dpset object for querying Ryu's DPSet application
self.dpset = kwargs['dpset']
# Setup logging
self.logger = get_logger(
self.logname, self.logfile, logging.DEBUG, 0)
# Set up separate logging for exceptions
self.exc_logger = get_logger(
self.exc_logname, self.exc_logfile, logging.DEBUG, 1)
# Set up a valve object for each datapath
self.valves = {}
self.config_hashes, valve_dps = dp_parser(
self.config_file, self.logname)
for valve_dp in valve_dps:
# pylint: disable=no-member
valve = valve_factory(valve_dp)
if valve is None:
self.logger.error(
'Hardware type not supported for DP: %s', valve_dp.name)
else:
self.valves[valve_dp.dp_id] = valve(valve_dp, self.logname)
self.gateway_resolve_request_thread = hub.spawn(
self.gateway_resolve_request)
self.host_expire_request_thread = hub.spawn(
self.host_expire_request)
self.dp_bgp_speakers = {}
self._reset_bgp()
# Register to API
api = kwargs['faucet_api']
api._register(self)
self.send_event_to_observers(EventFaucetAPIRegistered())
示例5: set_logging_level
def set_logging_level(level):
'''
Programmer can set level of logging he/she desires. Note: mostly used
internally for compiler development.
Args:
level (int): See Python's internal logging module.
Options are logging.CRITICAL, logging.INFO, logging.DEBUG, etc.
'''
util.get_logger().setLevel(level)
示例6: run
def run(self):
'''
Event loop. Keep on reading off queue and servicing.
'''
while True:
service_action = self.threadsafe_queue.get()
if __debug__:
util.get_logger().debug(
('Servicing action. Remaining queue size: %s' %
str(self.threadsafe_queue.qsize())),
extra= self.logging_info)
service_action.service()
示例7: loop_error_item
def loop_error_item(self, loggers=['validation']):
for meta, unit_datas in self._raw:
error_datas = []
for row_data in unit_datas:
error_count = 0
for logger in loggers:
errors = get_logger(logger, row_data)
error_count += len(errors) if errors else 0
for col_data in itertools.chain(row_data['raw'], row_data['eval'], row_data['extend']):
errors = get_logger(logger, col_data)
error_count += len(errors) if errors else 0
if error_count>0:
error_datas.append(row_data)
if len(error_datas)>0:
yield meta, error_datas
示例8: __init__
def __init__(self):
self.nodes = dict()
self.clients_pubsub = PubSub(self, pub_port=settings.CLIENT_SUB, sub_port=settings.CLIENT_PUB, broadcast=False)
self.nodes_pubsub = PubSub(self, pub_port=settings.NODE_SUB, sub_port=settings.NODE_PUB, parse_message=self.parse_message)
self.logger = util.get_logger("%s.%s" % (self.__module__, self.__class__.__name__))
Logger(self)
self.run()
示例9: __init__
def __init__(self, port):
ReliableChatServerSocket.__init__(self, port)
self.msg_acks = {} #hashcode -> [clients]
self.sent_msgs = {} #who has been sent what?
self.all_msgs = {} #hashcode -> msg
self.identity = {} #socket_ptr -> name
self.logger = get_logger(self)
示例10: router
def router():
_logger = get_logger(__name__)
if request.form.get("token") == os.environ.get("SLACK_WEBHOOK_SECRET"):
# Get info from incoming request
channel_id = request.form.get("channel_id")
user = request.form.get("user_name")
message = request.form.get("text")
_logger.info("Incoming message from {0} on {1}: {2}".format(channel_id, user, message))
# Parse and route
try:
response = parse_message(message, user)
except Exception as e:
response = fail(e, user)
slack_client = SlackClient(os.environ.get("SLACK_TOKEN"))
slack_client.api_call(
"chat.postMessage",
channel=channel_id,
username='lunch-bot',
icon_emoji=':sausage:',
**response
)
return Response(), 200
示例11: str_item_error
def str_item_error(self, row_data, loggers=['validation'], html=False):
link_str = '<br>' if html else '\n'
msg =u'错误信息:'
for logger in loggers:
msg += link_str
msg += u'--- 错误类型:{0} ---'.format(logger)
errors = get_logger(logger, row_data)
if errors and len(errors)>0:
msg += link_str
msg += ';'.join(errors)
for col_data in itertools.chain(row_data['raw'], row_data['eval'], row_data['extend']):
errors = get_logger(logger, col_data)
if errors and len(errors)>0:
msg += link_str
msg += '%s: %s' % (col_data['key'], ';'.join(errors))
return msg
示例12: __init__
def __init__(self, name, *args, **kwargs):
self.name = name
self.initializing = True
if LIVE: self.interface_kit = InterfaceKit()
self.manager = PubSub(self, pub_port=settings.NODE_PUB, sub_port=settings.NODE_SUB, sub_filter=self.name)
self.logger = util.get_logger("%s.%s" % (self.__module__, self.__class__.__name__))
self.initialize()
self.run()
示例13: __init__
def __init__(self):
self._logger = util.get_logger(__name__, log_file=self._log_file)
self._init_devices()
# Not sure if this is the right place for this screens saver object but
# I don't want to put it in busted() because that would instantiate it
# every time busted() is triggered
self._screen_saver = Screen_Saver()
示例14: __init__
def __init__(self, input, output, min, max, state, current_state):
self.input = input
self.min = min
self.max = max
self.output = output
self.state = state
self.current_state = current_state
self.logger = util.get_logger("%s.%s" % (self.__module__, self.__class__.__name__))
示例15: echo_error
def echo_error(self, loggers=['validation']):
error_total = 0
for meta, error_items in self._raw:
print self.str_meta(meta)
for row_data in error_items:
error_count = 0
for logger in loggers:
errors = get_logger(logger, row_data)
error_count += len(errors) if errors else 0
for col_data in itertools.chain(row_data['raw'], row_data['eval'], row_data['extend']):
errors = get_logger(logger, col_data)
error_count += len(errors) if errors else 0
if error_count>0:
error_total += error_count
print self.str_item(row_data)
print self.str_item_error(row_data, loggers=loggers)
print u'错误记录条数: {0}'.format(error_total)