本文整理汇总了Python中util.get_logger函数的典型用法代码示例。如果您正苦于以下问题:Python get_logger函数的具体用法?Python get_logger怎么用?Python get_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_logger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']
开发者ID:Baloc,项目名称:faucet,代码行数:31,代码来源:gauge.py
示例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)
开发者ID:JayThomason,项目名称:Waldo,代码行数:27,代码来源:waldoServiceActions.py
示例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)
开发者ID:JayThomason,项目名称:Waldo,代码行数:31,代码来源:waldoServiceActions.py
示例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())
开发者ID:Baloc,项目名称:faucet,代码行数:54,代码来源:faucet.py
示例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)
开发者ID:JayThomason,项目名称:Waldo,代码行数:11,代码来源:Waldo.py
示例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()
开发者ID:JayThomason,项目名称:Waldo,代码行数:12,代码来源:waldoEndpointServiceThread.py
示例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
开发者ID:gxsdfzmck,项目名称:theforce,代码行数:15,代码来源:__init__.py
示例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()
开发者ID:entone,项目名称:Automaton,代码行数:7,代码来源:manager.py
示例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)
开发者ID:brifinn,项目名称:Rally,代码行数:7,代码来源:rally.py
示例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
开发者ID:BenDundee,项目名称:bot-army,代码行数:26,代码来源:run_bot.py
示例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
开发者ID:gxsdfzmck,项目名称:theforce,代码行数:16,代码来源:__init__.py
示例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()
开发者ID:entone,项目名称:Automaton,代码行数:8,代码来源:__init__.py
示例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()
开发者ID:bjing,项目名称:no_more_donuts,代码行数:8,代码来源:donut_detector.py
示例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__))
开发者ID:entone,项目名称:Automaton,代码行数:8,代码来源:__init__.py
示例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)
开发者ID:gxsdfzmck,项目名称:theforce,代码行数:17,代码来源:__init__.py
示例16: _setup_logging
def _setup_logging():
'''
Internal function. Not to be used by programmer.
'''
DEFAULT_LOG_FILENAME = 'log.txt'
DEFAULT_LOGGING_LEVEL = logging.CRITICAL
format_ = (
'%(levelname)s : %(asctime)s.%(msecs)f: %(endpoint_string)s : %(mod)s \n %(message)s')
# '%(levelname)s : %(asctime)s.%(msecs).03d: %(endpoint_string)s : %(mod)s \n %(message)s')
logging.basicConfig(
format=format_, filename=DEFAULT_LOG_FILENAME, level=DEFAULT_LOGGING_LEVEL,
datefmt='%I:%M:%S')
util.get_logger().critical(
'***** New *****', extra={'mod': 'NEW', 'endpoint_string': 'NEW'})
util.lock_log('***** New *****')
开发者ID:JayThomason,项目名称:Waldo,代码行数:18,代码来源:Waldo.py
示例17: ofchannel_log
def ofchannel_log(self, ofmsgs):
if self.dp is not None:
if self.dp.ofchannel_log is not None:
self.ofchannel_logger = util.get_logger(
self.dp.ofchannel_log,
self.dp.ofchannel_log,
logging.DEBUG,
0)
for ofmsg in ofmsgs:
self.ofchannel_logger.debug(ofmsg)
开发者ID:davidjericho,项目名称:faucet,代码行数:10,代码来源:valve.py
示例18: main_test
def main_test():
import util
test_urls = {
'dd3322be6b143c6a842acdb4bb5e9f60': 'http://localhost/w/dl/20140728233100.ts',
# '0d851220f47e7aed4615aebbd5cd2c7a': 'http://localhost/w/dl/test.jpg'
}
log = util.get_logger()
ttttt(1, test_urls, log)
ttttt(3, test_urls, log)
ttttt(4, test_urls, log)
开发者ID:pkhopper,项目名称:vavava,代码行数:10,代码来源:httputil.py
示例19: ws_test
def ws_test(log=None):
if log is None:
import util
log = util.get_logger()
ws = WorkShop(tmin=5, tmax=20, log=log)
i = 0
total = 0
tasks = []
try:
ws.serve()
while True:
task = TaskTest(randint(0, 10), name='T_%05d' % i, log=log)
task.makeSubWorks()
assert task.subWorks is not None
# wk.cancel()
ws.addTask(task)
tasks.append(task)
i += 1
total += 1
log.error(' ||||||||||||||| tasks = %d', ws.currTaskSize)
if i < 190:
_sleep(0.3)
else:
_sleep(0.6)
if i > 200:
break
except Exception as e:
log.exception(e)
raise
finally:
# _sleep(1)
ws.setToStop()
ws.join()
canceled_total = unknow_total = archived_total = err_total = 0
for task in tasks:
log.error('[%s] status=%d', task.name, task.status)
if task.isArchived():
archived_total += 1
elif task.isError():
err_total += 1
elif task.status == 3:
canceled_total += 1
else:
unknow_total += 1
# if task.isArchived() == task.isError():
# _sleep(0.3)
# for wk in task.subworks:
# print wk.status
log.error('TASK: total=%d, exec=%d, arc=%d, canc=%d, err=%d, un=%d, clean=%d',
total, TaskTest.EXEC_TOTAL, archived_total, canceled_total,
err_total, unknow_total, TaskTest.CLEANUP)
log.error('WORK: total=%d, exec=%d', WorkTest.TOTAL, WorkTest.EXEC_TOTAL)
assert unknow_total == 0
assert TaskTest.CLEANUP == total
assert archived_total + err_total + canceled_total == TaskTest.TOTAL
开发者ID:pkhopper,项目名称:vavava,代码行数:55,代码来源:threadutil.py
示例20: ofchannel_log
def ofchannel_log(self, ofmsgs):
"""Log OpenFlow messages in text format to debugging log."""
if self.dp is not None:
if self.dp.ofchannel_log is not None:
self.ofchannel_logger = util.get_logger(
self.dp.ofchannel_log,
self.dp.ofchannel_log,
logging.DEBUG,
0)
for ofmsg in ofmsgs:
self.ofchannel_logger.debug(ofmsg)
开发者ID:harshad91,项目名称:faucet,代码行数:11,代码来源:valve.py
注:本文中的util.get_logger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论