Files
wlan-lanforge-scripts/py-scripts/sandbox/logger_example_1.py
Matthew Stidham 2c57e3e7b7 logger_example_1.py: Initial commit
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
2021-11-22 16:26:38 -08:00

25 lines
778 B
Python
Executable File

#!/usr/bin/python3
import logging
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--debug',
type=int,
default=2,
help="Set logging level, range 0 through 4. 0 is DEBUG, 4 is CRITICAL")
args = parser.parse_args()
levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]
logging.basicConfig(level=levels[args.debug])
logging.debug('This is debug output, level 0')
logging.info('This is info output, level 1')
logging.warning('This is warning output, level 2')
logging.error('This is error output, level 3')
logging.critical('This is error output, level 4')
if __name__ == "__main__":
main()