mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
log: Factorize boring/irrelevant log line filter definition
This commit is contained in:
parent
0a5bf3d021
commit
a9b0619f42
1 changed files with 27 additions and 38 deletions
|
@ -42,12 +42,36 @@ from yunohost.utils.packages import get_ynh_package_version
|
|||
from moulinette.utils.log import getActionLogger
|
||||
from moulinette.utils.filesystem import read_file, read_yaml
|
||||
|
||||
logger = getActionLogger("yunohost.log")
|
||||
|
||||
CATEGORIES_PATH = "/var/log/yunohost/categories/"
|
||||
OPERATIONS_PATH = "/var/log/yunohost/categories/operation/"
|
||||
METADATA_FILE_EXT = ".yml"
|
||||
LOG_FILE_EXT = ".log"
|
||||
|
||||
logger = getActionLogger("yunohost.log")
|
||||
BORING_LOG_LINES = [
|
||||
r"set [+-]x$",
|
||||
r"set [+-]o xtrace$",
|
||||
r"set [+-]o errexit$",
|
||||
r"set [+-]o nounset$",
|
||||
r"trap '' EXIT",
|
||||
r"local \w+$",
|
||||
r"local exit_code=(1|0)$",
|
||||
r"local legacy_args=.*$",
|
||||
r"local -A args_array$",
|
||||
r"args_array=.*$",
|
||||
r"ret_code=1",
|
||||
r".*Helper used in legacy mode.*",
|
||||
r"ynh_handle_getopts_args",
|
||||
r"ynh_script_progression",
|
||||
r"sleep 0.5",
|
||||
r"'\[' (1|0) -eq (1|0) '\]'$",
|
||||
r"\[?\['? -n '' '?\]\]?$",
|
||||
r"rm -rf /var/cache/yunohost/download/$",
|
||||
r"type -t ynh_clean_setup$",
|
||||
r"DEBUG - \+ echo '",
|
||||
r"DEBUG - \+ exit (1|0)$",
|
||||
]
|
||||
|
||||
|
||||
def log_list(limit=None, with_details=False, with_suboperations=False):
|
||||
|
@ -163,30 +187,7 @@ def log_show(
|
|||
if filter_irrelevant:
|
||||
|
||||
def _filter(lines):
|
||||
filters = [
|
||||
r"set [+-]x$",
|
||||
r"set [+-]o xtrace$",
|
||||
r"set [+-]o errexit$",
|
||||
r"set [+-]o nounset$",
|
||||
r"trap '' EXIT",
|
||||
r"local \w+$",
|
||||
r"local exit_code=(1|0)$",
|
||||
r"local legacy_args=.*$",
|
||||
r"local -A args_array$",
|
||||
r"args_array=.*$",
|
||||
r"ret_code=1",
|
||||
r".*Helper used in legacy mode.*",
|
||||
r"ynh_handle_getopts_args",
|
||||
r"ynh_script_progression",
|
||||
r"sleep 0.5",
|
||||
r"'\[' (1|0) -eq (1|0) '\]'$",
|
||||
r"\[?\['? -n '' '?\]\]?$",
|
||||
r"rm -rf /var/cache/yunohost/download/$",
|
||||
r"type -t ynh_clean_setup$",
|
||||
r"DEBUG - \+ echo '",
|
||||
r"DEBUG - \+ exit (1|0)$",
|
||||
]
|
||||
filters = [re.compile(f) for f in filters]
|
||||
filters = [re.compile(f) for f in BORING_LOG_LINES]
|
||||
return [
|
||||
line
|
||||
for line in lines
|
||||
|
@ -738,19 +739,7 @@ class OperationLogger(object):
|
|||
with open(self.log_path, "r") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
filters = [
|
||||
r"set [+-]x$",
|
||||
r"set [+-]o xtrace$",
|
||||
r"local \w+$",
|
||||
r"local legacy_args=.*$",
|
||||
r".*Helper used in legacy mode.*",
|
||||
r"args_array=.*$",
|
||||
r"local -A args_array$",
|
||||
r"ynh_handle_getopts_args",
|
||||
r"ynh_script_progression",
|
||||
]
|
||||
|
||||
filters = [re.compile(f_) for f_ in filters]
|
||||
filters = [re.compile(f_) for f_ in BORING_LOG_LINES]
|
||||
|
||||
lines_to_display = []
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue