errorlog2es.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:rdsmant 作者: JangYoungWhan 项目源码 文件源码
def validate_log_date(self, line):
    delta = timedelta(hours=2)

    m = REG_GENERAL_ERR.match(line)
    if m:
      log_time = datetime.strptime(m.group(1), "%Y-%m-%d %H:%M:%S")
      log_time = log_time.replace(tzinfo=tz.tzutc()).astimezone(zoneinfo.gettz(self._GENERAL_CONFIG["TIMEZONE"]))
      log_time = log_time.replace(tzinfo=None)
      if (self._now - log_time) > delta:
        return False
    elif BEGIN_DEADLOCK in line:
      m = REG_DEADLOCK.match(line)
      log_time = datetime.strptime(m.group(1), "%Y-%m-%d %H:%M:%S")
      log_time = log_time.replace(tzinfo=tz.tzutc()).astimezone(zoneinfo.gettz(self._GENERAL_CONFIG["TIMEZONE"]))
      log_time = log_time.replace(tzinfo=None)
      if (self._now - log_time) > delta:
        return False

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号