当前位置: 首页>>代码示例>>Python>>正文


Python log.get_task_logger方法代码示例

本文整理汇总了Python中celery.utils.log.get_task_logger方法的典型用法代码示例。如果您正苦于以下问题:Python log.get_task_logger方法的具体用法?Python log.get_task_logger怎么用?Python log.get_task_logger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在celery.utils.log的用法示例。


在下文中一共展示了log.get_task_logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_task

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def test_task():
    from pylogctx import context

    app = Celery(task_cls=LoggingTask)

    @app.task
    def my_task():
        context.update(taskField='RUNNED')
        logger = get_task_logger(current_task.name)
        logger.info("I log!")
        return context.as_dict()

    result = my_task.apply()
    if VERSION.major < 4:
        result.maybe_reraise()
    else:
        result.maybe_throw()
    fields = result.result
    assert 'taskField' in fields
    assert not context.as_dict() 
开发者ID:peopledoc,项目名称:pylogctx,代码行数:22,代码来源:test_celery.py

示例2: test_old_task

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def test_old_task():
    from pylogctx import context

    app = Celery(task_cls=OldLoggingTask)

    @app.task
    def my_task():
        logger = get_task_logger(current_task.name)
        logger.info("I log!")
        return context.as_dict()

    result = my_task.apply()
    if VERSION.major < 4:
        result.maybe_reraise()
    else:
        result.maybe_throw()
    fields = result.result
    assert 'taskField' in fields
    assert not context.as_dict() 
开发者ID:peopledoc,项目名称:pylogctx,代码行数:21,代码来源:test_celery.py

示例3: __call__

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def __call__(self, *args, **kwargs):
        self.logger = get_task_logger('que.mgmt')
        task = 'MgmtTask %s%s' % (self.name, args[:2])
        tidlock = kwargs.pop('tidlock', None)
        check_user_tasks = kwargs.pop('check_user_tasks', False)
        kwargs.pop('cache_result', None)
        kwargs.pop('cache_timeout', None)
        kwargs.pop('nolog', None)
        tid = self.request.id

        if tidlock:
            task_lock = TaskLock(tidlock, desc=task, reverse_key=tid, logger=self.logger)
        else:
            task_lock = NoLock()

        try:
            if check_user_tasks:  # Wait for task to appear in UserTasks - bug #chili-618
                UserTasks.check(tid, logger=self.logger)  # Will raise an exception in case the task does not show up

            task_lock.task_check()  # Will raise an exception in case the lock does not exist

            return super(MgmtTask, self).__call__(tid, *args, **kwargs)  # run()
        finally:
            task_lock.delete() 
开发者ID:erigones,项目名称:esdc-ce,代码行数:26,代码来源:mgmt.py

示例4: __init__

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def __init__(self, ps_client, es_client, array_context):
        self._ps_client = ps_client;
        self._es_client = es_client;
        self._array_name = array_context.name
        self._array_id = array_context.id
        self._data_ttl = array_context.data_ttl
        self.logger = get_task_logger(__name__) 
开发者ID:pure-garyyang,项目名称:pureelk,代码行数:9,代码来源:purecollector.py

示例5: delete_pipe

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def delete_pipe(pipe_id):
    logger = get_task_logger(__name__)
    logger.info("DELETED BY CELERY {}".format(pipe_id))
    lostconfig = LOSTConfig()
    dbm = DBMan(lostconfig)
    pipeline.delete(dbm, pipe_id)
    dbm.close_session() 
开发者ID:l3p-cv,项目名称:lost,代码行数:9,代码来源:tasks.py

示例6: send_life_sign

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def send_life_sign():
    logger = get_task_logger(__name__)
    lostconfig = LOSTConfig()
    dbm = DBMan(lostconfig)
    worker = dbm.get_worker(lostconfig.worker_name)
    if worker is None:
        register_worker(dbm, lostconfig)
        logger.info('Registered worker: {}'.format(lostconfig.worker_name))
    else:
        worker.timestamp = datetime.utcnow()
        dbm.add(worker)
        dbm.commit()
        #logger.info('Sent lifesign: {}'.format(worker.worker_name))
    dbm.close_session() 
开发者ID:l3p-cv,项目名称:lost,代码行数:16,代码来源:worker.py

示例7: __init__

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def __init__(self, dbm, pipe, lostconfig):
        '''
        :type dbm: lost.db.access.DBMan
        :type pipe: lost.db.model.Pipe
        '''
        super().__init__(dbm=dbm, pipe=pipe)
        self.lostconfig = lostconfig #type: lost.logic.config.LOSTConfig
        self.file_man = FileMan(self.lostconfig)
        # self.logger = lost.logic.log.get_file_logger(
        #     'Executor: {}'.format(self.lostconfig.env), 
        #     self.file_man.app_log_path)
        self.logger = get_task_logger(__name__) 
开发者ID:l3p-cv,项目名称:lost,代码行数:14,代码来源:cron.py

示例8: log

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def log(self):
        return get_task_logger(self.name) 
开发者ID:opendatateam,项目名称:udata,代码行数:4,代码来源:tasks.py

示例9: get_logger

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def get_logger(name):
    logger = get_task_logger(name)
    return logger 
开发者ID:opendatateam,项目名称:udata,代码行数:5,代码来源:tasks.py

示例10: get_logger

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def get_logger(name):
    """ Helper function to return a  valid logger object

    Args:
        name (str): The name of the logger. Typically: __name__.

    Returns:
        Logger: A logger object for sending messages to the logging system
    """
    return get_task_logger(name) 
开发者ID:AustralianSynchrotron,项目名称:lightflow,代码行数:12,代码来源:logger.py

示例11: process_wechat_query_auth_code_test

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def process_wechat_query_auth_code_test(FromUserName, query_auth_code):
    """
    处理发布前微信的自动化测试query_auth_code
    """
    logger = get_task_logger('process_wechat_query_auth_code_test')
    logger.info(FromUserName)
    logger.info(query_auth_code)
    component = get_component()
    client = component.get_client_by_authorization_code(query_auth_code)
    client.message.send_text(FromUserName, query_auth_code+'_from_api') 
开发者ID:wechatpy,项目名称:django-wechat-example,代码行数:12,代码来源:tasks.py

示例12: refresh_all_wechat_token

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def refresh_all_wechat_token(self):
    """
    定时1小时,刷新所有已授权公众号
    """
    logger = get_task_logger('refresh_all_wechat_token')
    for wechat in Wechat.objects.exclude(appid=settings.TEST_APPID).all():
        if not wechat.authorized:
            logger.error('公众号{0}失去授权'.format(wechat.appid))
            continue
        refresh_wechat_token.delay(wechat.appid) 
开发者ID:wechatpy,项目名称:django-wechat-example,代码行数:12,代码来源:tasks.py

示例13: refresh_wechat_token

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def refresh_wechat_token(self, appid):
    """
    刷新已授权公众号
    """
    logger = get_task_logger('refresh_wechat_token')
    wechat = Wechat.objects.get(appid=appid)
    if not wechat.authorized:
        logger.error('公众号{0}失去授权'.format(wechat.appid))
        return None
    try:
        result = wechat.client.fetch_access_token()
        logger.info(result)
    except Exception as e:
        logger.error(u'刷新已授权公众号{0}失败:{1}'.format(appid, str(e))) 
开发者ID:wechatpy,项目名称:django-wechat-example,代码行数:16,代码来源:tasks.py

示例14: log

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def log(self):
        return get_task_logger("%s.%s" % (__name__, self.alert_name)) 
开发者ID:mozilla,项目名称:MozDef,代码行数:4,代码来源:alerttask.py

示例15: __call__

# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_task_logger [as 别名]
def __call__(self, cmd, *args, **kwargs):
        self.logger = get_task_logger('que.tasks')
        self.all_done = False
        task = 'Task %s("%s")' % (self.name, cmd)
        lock = kwargs.pop('lock', False)
        block = kwargs.pop('block', None)
        check_user_tasks = kwargs.pop('check_user_tasks', False)
        tid = self.request.id
        blocked = False

        if lock:
            task_lock = TaskLock(lock, desc=task, reverse_key=tid, logger=self.logger)
        else:
            task_lock = NoLock()

        try:
            if check_user_tasks:  # Wait for task to appear in UserTasks - bug #chili-618
                UserTasks.check(tid, logger=self.logger)  # Will raise an exception in case the task does not show up

            task_lock.task_check()  # Will raise an exception in case the lock does not exist

            if block and redis.exists(block):
                blocked = True
                self.retry(exc=TaskRetry(None))  # Will raise special exception

            return super(MetaTask, self).__call__(cmd, *args, **kwargs)  # run()
        finally:
            if not blocked:  # Lock must _not_ be deleted when failing on retry
                task_lock.delete() 
开发者ID:erigones,项目名称:esdc-ce,代码行数:31,代码来源:tasks.py


注:本文中的celery.utils.log.get_task_logger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。