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
No related branches found
No related tags found
No related merge requests found
......@@ -51,14 +51,17 @@ parser.add_argument('unittest_args', nargs='*')
args, unknown = parser.parse_known_args()
sys.argv[1:] = args.unittest_args
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
if args.quite:
log_level = logging.WARNING
stream_handler.setLevel(logging.WARNING)
else:
log_level = logging.DEBUG
logging.basicConfig(level=log_level,
format='%(asctime)s %(levelname)-8s: %(message)s',
datefmt='%H:%M')
stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)-8s: %(message)s', datefmt='%H:%M'))
logger.addHandler(stream_handler)
def initializer(func):
......@@ -102,6 +105,7 @@ class BaseSearchClass(object):
' Log output to a log-file, requires class to have outdir and label '
logfilename = '{}/{}.log'.format(self.outdir, self.label)
fh = logging.FileHandler(logfilename)
fh.setLevel(logging.INFO)
fh.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)-8s: %(message)s',
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