This commit is contained in:
Nicola Spanti 2015-09-16 23:22:56 +00:00
commit 939bce0548
3 changed files with 62 additions and 1 deletions

View file

@ -1,6 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" License
Copyright (C) 2015 YunoHost
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see https://www.gnu.org/licenses
"""
import sys
import os
@ -54,6 +73,10 @@ def _parse_argv():
argv = list(sys.argv)
argv.pop(0)
if '--cache' in argv:
global USE_CACHE
USE_CACHE = True
argv.remove('--cache')
if '--no-cache' in argv:
global USE_CACHE
USE_CACHE = False
@ -66,6 +89,10 @@ def _parse_argv():
global LOGGERS_LEVEL
LOGGERS_LEVEL = 'DEBUG'
argv.remove('--debug')
if '--no-debug' in argv:
global LOGGERS_LEVEL
LOGGERS_LEVEL = 'INFO'
argv.remove('--no-debug')
if '--verbose' in argv:
global LOGGERS_HANDLERS
if 'console' not in LOGGERS_HANDLERS:

View file

@ -1,6 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" License
Copyright (C) 2015 YunoHost
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see https://www.gnu.org/licenses
"""
import sys
import os.path
@ -54,6 +73,10 @@ def _parse_argv():
argv = list(sys.argv)
argv.pop(0)
if '--no-cache' in argv:
global USE_CACHE
USE_CACHE = False
argv.remove('--no-cache')
if '--no-cache' in argv:
global USE_CACHE
USE_CACHE = False
@ -66,6 +89,10 @@ def _parse_argv():
global LOGGERS_LEVEL
LOGGERS_LEVEL = 'DEBUG'
argv.remove('--debug')
if '--no-debug' in argv:
global LOGGERS_LEVEL
LOGGERS_LEVEL = 'INFO'
argv.remove('--no-debug')
if '--verbose' in argv:
global LOGGERS_HANDLERS
if 'console' not in LOGGERS_HANDLERS:

View file

@ -225,6 +225,13 @@ def service_status(names=[]):
return result
def _get_log_file_list_in_dir(log_path):
return [
f for f in os.listdir(log_path)
if os.path.isfile(os.path.join(log_path, f)) and f[-4:] == '.log'
]
def service_log(name, number=50):
"""
Log every log files of a service
@ -247,7 +254,7 @@ def service_log(name, number=50):
for log_path in log_list:
if os.path.isdir(log_path):
for log in [ f for f in os.listdir(log_path) if os.path.isfile(os.path.join(log_path, f)) and f[-4:] == '.log' ]:
for log in _get_log_file_list_in_dir(log_path):
result[os.path.join(log_path, log)] = _tail(os.path.join(log_path, log), int(number))
else:
result[log_path] = _tail(log_path, int(number))