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


Python Log.level方法代码示例

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


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

示例1: save_log

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import level [as 别名]
def save_log(request):
    '''记录收到的警告记录'''
    level = request.POST.get('level', '')
    msg  = request.POST.get('msg', '')
    
    if not level or not msg:
        return HttpResponse(u'参数错误')
    
    try:
        level = int(level)
    except:
        return HttpResponse(u'参数错误')

    ip = request.META.get('REMOTE_ADDR', '')
    settings = ServerSettings.objects.filter(server_ip=ip)
    if settings:
        '''找到服务器设置'''
        setting = settings[0]
        #记录
        log = Log()
        log.server = setting
        log.level = level
        log.content = msg
        log.save()
        print 'log: ', msg
        #检查是否推送
        push_logs = setting.pushlog_set.order_by('-submit_date')
        
        is_push = False
        if push_logs:
            #计算时间
            push_log = push_logs[0]
            now = datetime.datetime.now()
            interval = now - push_log.submit_date
            if interval.days > 0 or interval.seconds > 30*60:
                '''推送间隔要大于30分钟'''
                is_push = True
        else:
            '''没有记录,则要记录'''
            is_push = True
        if is_push:
            '''需要推送'''
            print '!!!!!!!!!!!!!!push msg: ', msg
            
            push_log = PushLog()
            push_log.server = setting
            push_log.content = msg
            push_log.save()
    
        return HttpResponse('log ok')
        
    else:
        '''没有这个服务器设置'''
        return HttpResponse('fail, not setting about this server')
开发者ID:lvshuchengyin,项目名称:mycode,代码行数:56,代码来源:views.py

示例2: _to_logs

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import level [as 别名]
 def _to_logs(self, hits):
     logs = []
     for hit in hits:
         log = Log()
         log.id = hit.meta.id
         log.filename = hit.filename
         log.level = hit.level
         log.message = hit.message
         log.created_at = utils.to_datetime(hit.created_at, '%Y-%m-%d')
         logs.append(log)
     return logs
开发者ID:gustavohenrique,项目名称:elasticlog,代码行数:13,代码来源:elasticlog.py

示例3: emit

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import level [as 别名]
 def emit(self, record):
     log = Log()
     obj = getattr(record, "obj", None)
     if obj:
         log.obj = unicode(obj)
     log.name = unicode(record.name)
     log.level = unicode(record.levelname)
     log.module = unicode(record.module)
     log.func_name = unicode(record.funcName)
     log.line_no = unicode(record.lineno)
     log.thread = unicode(record.thread)
     log.thread_name = unicode(record.threadName)
     log.process = unicode(record.process)
     log.message = unicode(record.msg)
     log.args = unicode(record.args)
     db.session.add(log)
     db.session.commit()
开发者ID:PuZheng,项目名称:Flask-DataBrowser,代码行数:19,代码来源:basemain.py

示例4: emit

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import level [as 别名]
 def emit(self, record):
     log = Log()
     obj = getattr(record, "obj", None)
     if obj:
         log.obj = repr(obj)
     log.name = record.name
     log.level = record.levelname
     log.module = record.module
     log.func_name = record.funcName
     log.line_no = record.lineno
     log.thread = record.thread
     log.thread_name = record.threadName
     log.process = record.process
     log.message = record.msg
     log.args = str(record.args)
     db.session.add(log)
     db.session.commit()
开发者ID:xiechao06,项目名称:Flask-DataBrowser,代码行数:19,代码来源:basemain.py

示例5: gen

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import level [as 别名]
def gen(level, description):
    log = Log()
    log.description = description
    log.level = level
    log.create_date = timezone.now()
    log.save()
开发者ID:tank39133,项目名称:zvm_dashboard,代码行数:8,代码来源:log.py


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