本文整理汇总了Python中utils.Logger.exception方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.exception方法的具体用法?Python Logger.exception怎么用?Python Logger.exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Logger
的用法示例。
在下文中一共展示了Logger.exception方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _Job
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import exception [as 别名]
class _Job(object):
def __init__(self):
self.log = Logger(self.__class__.__name__, fh)
self.log.debug("Job is created")
def execute(self, **kwargs):
try:
self.log.debug("Start job with kwargs=%s" % kwargs)
self._execute(**kwargs)
self.log.debug("Finish job successful")
except Exception as e:
self.log.exception("Error during job execution")
subject = 'Tasker Information. Произошла ошибка в скрипте %s' % self.__class__.__name__
self.log.debug(subject)
# send_email(subject, as_text(e.message),
# send_from=SMTP_SETTINGS['username'],
# server=SMTP_SETTINGS['server'],
# port=SMTP_SETTINGS['port'],
# user=SMTP_SETTINGS['username'],
# passwd=SMTP_SETTINGS['password'],
# dest_to=ERROR_EMAILS)
def _execute(self, **kwargs):
raise NotImplementedError("%s._execute" % self.__class__.__name__)
@classmethod
def run(cls, **kwargs):
log.debug("in _Job.run!")
return cls().execute(**kwargs)
示例2: SchedulerController
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import exception [as 别名]
class SchedulerController(object):
def __init__(self, request, scheduler):
self.log = Logger(self.__class__.__name__, fh)
self._request = request
self._scheduler = scheduler
def call(self, *args, **kwargs):
try:
request_info = get_request_info(self._request)
self.log.debug("Start process request: %s, %s, %s" %
(request_info.url, request_info.data, request_info.method))
data = self._call(*args, **kwargs)
self.log.debug('Finished')
return data
except Exception, e:
self.log.exception('Error during %s call' % self.__class__.__name__)
return render_template('error.html', error=e.message) # TODO шаблон
示例3: IndexController
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import exception [as 别名]
class IndexController(object):
def __init__(self, request, scheduler):
self.request = request
self.scheduler = scheduler
self.log = Logger(self.__class__.__name__, fh)
def call(self):
try:
self.log.debug("Start process request:" % self.request)
sched_status = self.scheduler.state
job_list = JobListController(self.request, self.scheduler).call()
data = render_template('index.html', data=job_list, status=sched_status)
self.log.debug("Finished")
return data
except Exception, e:
self.log.exception('Error during %s call' % self.__class__.__name__)
return render_template('error.html', errors=[e.message])
示例4: Logger
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import exception [as 别名]
fh = logging.FileHandler(os.path.join(config.LOG_TO, config.LOGGER.get('file')))
fh.setLevel(config.LOGGER.get('level'))
fh.setFormatter(config.LOGGER.get('formatter'))
log = Logger("IBotManager", fh)
modules = get_all_modules()
threads = [Thread(target=InstaBot(**get_config_from_module(module_name[:-3])).new_auto_mod,
name=module_name[:-3]) for module_name in modules]
for t in threads:
try:
log.debug("Try start '%s' bot" % t.name)
t.start()
log.debug("Successfully start '%s' bot." % t.name)
except Exception as ex:
log.exception("Error during work bot")
[t.join() for t in threads if t.is_alive()]
def stop_all_process():
signal.alarm(1)
atexit.register(stop_all_process)
time.sleep(5)