Commit c5bec666 authored by 金凯强's avatar 金凯强 🎨

获取日志修改

parent fcd3f026
Pipeline #21258 passed with stage
in 22 seconds
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import datetime import datetime
import os import os
import re
import shutil import shutil
import time import time
...@@ -214,11 +215,16 @@ where A.log_id={log_id}''' ...@@ -214,11 +215,16 @@ where A.log_id={log_id}'''
since_time = args.get('since_time', None) since_time = args.get('since_time', None)
if isinstance(since_time, str): if isinstance(since_time, str):
since_time = datetime.datetime.strptime(since_time, "%Y-%m-%d %H:%M:%S") since_time = int(datetime.datetime.timestamp(datetime.datetime.strptime(since_time, "%Y-%m-%d %H:%M:%S")))
tail = 'all'
else: else:
since_time = None since_time = None
tail = '200'
logs = docker_client.logs('install_api', tail=200, since=since_time) logs = docker_client.logs('install_api', tail=tail, since=since_time)
if isinstance(logs, bytes): if isinstance(logs, bytes):
logs = logs.decode() logs = logs.decode()
return logs
# 去除所有含有debug信息的日志
filtered_logs = re.sub('(\[20.*-.*DEBUG.*\\n)', '', logs)
return filtered_logs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment