Skip to content
Snippets Groups Projects
Commit 156ca01c authored by Nick Bearson's avatar Nick Bearson
Browse files

correct the default logging level, and clamp to the accepted logging values (#11)

parent a90ee80f
No related branches found
No related tags found
1 merge request!52020 02 10 beta1 high priority
......@@ -28,7 +28,7 @@ def create_parser():
import argparse
parser = argparse.ArgumentParser(description=parse_desc)
parser.add_argument('-v', '--verbose', dest='verbosity', action="count", default=0,
help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG (default INFO)')
help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG (default ERROR)')
parser.add_argument('-l', '--log', dest="log_fn", default=None,
help="specify the log filename")
# from Requirements: "Output is Gridded GLM in the native glmtools NetCDF4 format, with a user option to produce AWIPS-compatible NetCDF tiles as described below"
......@@ -183,7 +183,8 @@ if __name__ == '__main__':
# Configure logging
levels = [logging.ERROR, logging.WARN, logging.INFO, logging.DEBUG]
logging.basicConfig(level=levels[min(3, args.verbosity)], filename=args.log_fn)
clamp = lambda n, minn, maxn: max(min(maxn, n), minn) # used below to keep us from going off the end of the logging levels
logging.basicConfig(level=levels[clamp(args.verbosity, 0, len(levels)-1)], filename=args.log_fn)
if levels[min(3, args.verbosity)] > logging.DEBUG:
import warnings
warnings.filterwarnings("ignore")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment