logdemo.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import logging
00004 import nasa_common_logging
00005 import traceback
00006 
00007 # THIS TESTS LOADING A FILE WITH configure_custom_logging()
00008 # import os
00009 # import rospkg
00010 # ncl_path = rospkg.RosPack().get_path('nasa_common_logging')
00011 # config_file = os.path.join(ncl_path, 'share', 'logging.json')
00012 # nasa_common_logging.logging_utils.configure_custom_logging_file(config_file)
00013 
00014 # THIS TESTS LOADING COMMON CONFIG
00015 nasa_common_logging.logging_utils.configure_common_logging()
00016 
00017 logger = logging.getLogger(__name__)
00018 
00019 logger.info('hello world')
00020 logger.log(nasa_common_logging.log_level['error'], 'hey world!')
00021 
00022 try:
00023     a = 1. / 0.
00024 except ZeroDivisionError as e:
00025     trace = traceback.format_exc()
00026     logger.error(str(trace))
00027 
00028 sublog = logger.getChild('sub')
00029 sublog.log(nasa_common_logging.log_level['CRITICAL'], 'for real, world, where you at?!')
00030 
00031 my_custom_logging_config = nasa_common_logging.logging_utils.get_common_logging_configuration()
00032 my_custom_logging_config['handlers']['console']['formatter'] = 'brief'
00033 nasa_common_logging.logging_utils.configure_custom_logging(my_custom_logging_config)
00034 logger.log(nasa_common_logging.log_level['warn'], 'custom log format')


nasa_common_logging
Author(s):
autogenerated on Sun Feb 3 2019 03:42:09