better_launch.ros.logging
¶
Module for the launch specific logging taken from ROS2.
.. seealso::
`ROS2 rclpy/logging.py <https://github.com/ros2/launch/blob/rolling/launch/launch/logging/logging.py>`_
LaunchConfig
¶
Launch Logging Configuration class.
log_handler_factory
property
writable
¶
log_handler_factory
Get the log_handler_factory, generating it if necessary.
get_log_file_handler
¶
get_log_file_handler(file_name='launch.log')
Get the logging handler to a log file.
See launch_config() documentation for application wide log file logging configuration.
:param: file_name of the log file whose handler is to be retrieved. :return: the logging handler associated to the file (always the same once constructed).
get_log_file_path
¶
get_log_file_path(file_name='launch.log')
Get the absolute path to the given log file.
:param: file_name of the log file from which to get the absolute path. :return: the absolute path to the log file.
get_screen_handler
¶
get_screen_handler()
Get the one and only screen logging handler.
See launch_config() documentation for screen logging configuration.
set_log_format
¶
set_log_format(log_format, *, log_style=None)
Set up launch log file format.
:param log_format: the format used when logging to the main launch log file,
as expected by the logging.Formatter constructor.
Alternatively, the 'default' alias can be given to log verbosity level,
logger name and logged message.
This format can also be overridden by the environment variable
'OVERRIDE_LAUNCH_LOG_FORMAT'.
:param log_style: the log style used if no alias is given for log_format.
No style can be provided if a format alias is given.
set_screen_format
¶
set_screen_format(screen_format, *, screen_style=None)
Set up screen formats.
For the screen_format argument there are a few aliases:
- 'default' to log verbosity level, logger name and logged message
- 'default_with_timestamp' to add timestamps to the 'default' format
:param screen_format: format specification used when logging to the screen,
as expected by the logging.Formatter constructor.
Alternatively, aliases for common formats are available, see above.
This format can also be overridden by the environment variable
'OVERRIDE_LAUNCH_SCREEN_FORMAT'.
:param screen_style: the screen style used if no alias is used for
screen_format.
No style can be provided if a format alias is given.
get_logger
¶
get_logger(name=None) -> logging.Logger
Get named logger, configured to output to screen and launch main log file.
get_output_loggers
¶
get_output_loggers(process_name, output_config)
Get the stdout and stderr output loggers for the given process name.
The output_config may be a dictionary with one or more of the optional keys 'stdout', 'stderr', or 'both' (stdout and stderr combined) which represent the various process output sources, and values for those keys to assign one or more logging destinations to the source. The logging destination values may be:
- 'screen': log it to the screen,
- 'log': log it to launch log file, or
- 'own_log': log it to a separate log file.
When logging the stdout and stderr separately, the log file names follow
the <process_name>-<source>.log pattern where <source> is either
'stdout' or 'stderr'
When the 'both' logging destination is used the log file name follows the
<process_name>.log pattern.
The "launch log file" is a log file which is create for each run of the launch.LaunchService, and at least captures the log output from launch itself, but may also include output from subprocess's if configured so.
Alternatively, the output_config parameter may be a string which represents one of a couple available aliases for common logging configurations. The available aliases are:
- 'screen': stdout and stderr are logged to the screen,
- 'log': stdout and stderr are logged to launch log file and stderr to the screen,
- 'both': both stdout and stderr are logged to the screen and to launch main log file,
- 'own_log' for stdout, stderr and their combination to be logged to their own log files, and
- 'full' to have stdout and stderr sent to the screen, to the main launch log file, and their own separate and combined log files.
:param process_name: the process-like action whose outputs want to be logged. :param output_config: configuration for the output loggers, see above for details. :returns: a tuple with the stdout and stderr output loggers.
log_launch_config
¶
log_launch_config(*, logger=logging.root)
Log logging configuration details relevant for a user with the given logger.