No version for distro humble. Known supported distros are highlighted in the buttons above.
No version for distro jazzy. Known supported distros are highlighted in the buttons above.
No version for distro rolling. Known supported distros are highlighted in the buttons above.
No version for distro noetic. Known supported distros are highlighted in the buttons above.
No version for distro ardent. 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 crystal. Known supported distros are highlighted in the buttons above.
No version for distro eloquent. Known supported distros are highlighted in the buttons above.
No version for distro dashing. Known supported distros are highlighted in the buttons above.
No version for distro galactic. Known supported distros are highlighted in the buttons above.
No version for distro foxy. Known supported distros are highlighted in the buttons above.
No version for distro iron. 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 jade. 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.4.0 |
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 | 2021-02-19 |
Dev Status | MAINTAINED |
CI status | Continuous Integration |
Released | UNRELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
nasa_common_logging package
Additional Links
No additional links.
Maintainers
- Philip Strawser
Authors
No additional authors.
nasa_common_logging
About
See package.xml for version and maintainer information.
See LICENSE.md for complete license information.
This C++ library and Python package provide a standard way to instantiate, configure, and use logging. 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
#include "nasa_common_logging/Logger.h"
int main(int argc, char** argv)
{
// use log() for simple messages
// requires a category that describes the source of the log message, then a severity level, then a standard std::string message.
NasaCommonLogging::Logger::log("gov.nasa.nasa_common_logging.logdemo", log4cpp::Priority::WARN, "This is a warning!");
// use getCategory() for streamed messages
// requires a category that describes the source of the log messages, then a severity level, then any number of stream objects
NasaCommonLogging::Logger::getCategory("gov.nasa.nasa_common_logging.logdemo") << log4cpp::Priority::ERROR << "This is error: " << 42;
return 0;
}
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
Change Log
3.4.0
- Added method to allow for passing in a logging config file for C++ logging
- Updated ci such that py package allows failures
- Python 2 and Python 3 compatibility
- Remove trusty build, package and deploy CI jobs
- Run Python unit tests in CI
- Check if
/dev/log
exists before attempting to configure logger with syslog - Added LICENSE.md
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
This package does not provide any links to tutorials in it's rosindex metadata.
You can check on the ROS Wiki Tutorials page for the package.
Package Dependencies
Deps | Name |
---|---|
catkin | |
nasa_common_cmake | |
log4cpp | |
roslib |
System Dependencies
No direct system dependencies.
Dependant Packages
No known dependants.
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 Robotics Stack Exchange
No version for distro hydro. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.