No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.
No version for distro lunar. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
|
nasa_common_logging package from nasa_common_logging reponasa_common_logging |
Package Summary
| Tags | No category tags. |
| Version | 3.3.1 |
| License | NASA-1.3 |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://gitlab.com/nasa-jsc-robotics/nasa_common_logging.git |
| VCS Type | git |
| VCS Version | develop |
| Last Updated | 2019-01-31 |
| Dev Status | MAINTAINED |
| Released | UNRELEASED |
Package Description
nasa_common_logging package
Additional Links
No additional links.
Maintainers
- Philip Strawser
Authors
No additional authors.
nasa_common_logging
Provides a standard way to instantiate, configure, and use logging in C++ and Python code. The C++ system provides a singleton Logger class as a front-end for log4cpp. The Python system provides methods that help load a common or custom configuration into the standard logging infrastructure.
C++ Example
todo
Python Examples
Using nasa_common_logging defaults:
import logging
import nasa_common_logging
nasa_common_logging.logging_utils.configure_common_logging()
logger = logging.getLogger(__name__)
logger.info('hello world')
logger.log(nasa_common_logging.log_level['error'], 'hey world!')
sublog = logger.getChild('sub')
sublog.log(nasa_common_logging.log_level['CRITICAL'], 'for real, world, where you at?!')
my_custom_logging_config = nasa_common_logging.logging_utils.get_common_logging_configuration()
my_custom_logging_config['handlers']['console']['formatter'] = 'brief'
nasa_common_logging.logging_utils.configure_custom_logging(my_custom_logging_config)
logger.log(nasa_common_logging.log_level['warn'], 'custom log format')
Using nasa_common_logging loading a custom config file:
#!/usr/bin/env python
import logging
import nasa_common_logging
import os
import rospkg
ncl_path = rospkg.RosPack().get_path('nasa_common_logging')
config_file = os.path.join(ncl_path, 'share', 'logging.json')
nasa_common_logging.logging_utils.configure_custom_logging_file(config_file)
Using nasa_common_logging, overriding the defaults:
import logging
import nasa_common_logging
# Set the log level:
nasa_common_logging.configure_common_logging(level='WARNING')
# Override the handlers to only use a syslog and file handler
# All options are 'syslog', 'file', 'socket', and 'console'
nasa_common_logging.configure_common_logging(handlers=['console', 'file'])
# Override the file path. This will log to `~/.log/myApp.log`
nasa_common_logging.configure_common_logging(file_path='myApp.log')
# This will log to `/usr/local/log/myApp.log`
nasa_common_logging.configure_common_logging(file_path='/usr/local/log/myApp.log')
logger = logging.getLogger(__name__)
logger.info('hello world!')
One could also grab the default config, modify it, and set it. The config is a python dictionary.
import logging
import nasa_common_logging
config = nasa_common_logging.get_common_logging_configuration()
config['root']['level'] = 'WARNING'
config['root']['handlers'].append('file')
nasa_common_logging.configure_custom_logging(config)
CHANGELOG
Changelog
3.3.1
- fixing source field in logging.conf
3.3.0
- Added a Python logging .conf file and a method to find it
- Changed maintainer
Wiki Tutorials
See ROS Wiki Tutorials for more details.
Source Tutorials
Not currently indexed.
Dependant Packages
Launch files
No launch files found
Messages
No message files found.
Services
No service files found
Plugins
No plugins found.
Recent questions tagged nasa_common_logging at answers.ros.org
No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro jade. Known supported distros are highlighted in the buttons above.
No version for distro hydro. Known supported distros are highlighted in the buttons above.