mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	logger_example_1.py: Initial commit
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		
							
								
								
									
										25
									
								
								py-scripts/sandbox/logger_example_1.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								py-scripts/sandbox/logger_example_1.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/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() | ||||
		Reference in New Issue
	
	Block a user
	 Matthew Stidham
					Matthew Stidham