Skip to content
Snippets Groups Projects
Commit c825b5eb authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Fixes logging level

Updates the logging initialisation so that, when called with -q flag,
the log file is still written with INFO level log messages (only the
console output is supressed).
parent c2f95953
Branches
Tags
No related merge requests found
...@@ -51,14 +51,17 @@ parser.add_argument('unittest_args', nargs='*') ...@@ -51,14 +51,17 @@ parser.add_argument('unittest_args', nargs='*')
args, unknown = parser.parse_known_args() args, unknown = parser.parse_known_args()
sys.argv[1:] = args.unittest_args sys.argv[1:] = args.unittest_args
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
if args.quite: if args.quite:
log_level = logging.WARNING stream_handler.setLevel(logging.WARNING)
else: else:
log_level = logging.DEBUG stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(logging.Formatter(
logging.basicConfig(level=log_level, '%(asctime)s %(levelname)-8s: %(message)s', datefmt='%H:%M'))
format='%(asctime)s %(levelname)-8s: %(message)s', logger.addHandler(stream_handler)
datefmt='%H:%M')
def initializer(func): def initializer(func):
...@@ -102,6 +105,7 @@ class BaseSearchClass(object): ...@@ -102,6 +105,7 @@ class BaseSearchClass(object):
' Log output to a log-file, requires class to have outdir and label ' ' Log output to a log-file, requires class to have outdir and label '
logfilename = '{}/{}.log'.format(self.outdir, self.label) logfilename = '{}/{}.log'.format(self.outdir, self.label)
fh = logging.FileHandler(logfilename) fh = logging.FileHandler(logfilename)
fh.setLevel(logging.INFO)
fh.setFormatter(logging.Formatter( fh.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)-8s: %(message)s', '%(asctime)s %(levelname)-8s: %(message)s',
datefmt='%y-%m-%d %H:%M')) datefmt='%y-%m-%d %H:%M'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment