rclpy.impl.rcutils_logger module
- class rclpy.impl.rcutils_logger.CallerId(frame: FrameType | None = None)
Bases:
CallerId
Create new instance of CallerId(function_name, file_path, line_number, last_index)
- class rclpy.impl.rcutils_logger.LoggingArgs
Bases:
LoggingFilterArgs
- name: str
- once: bool
- skip_first: bool
- throttle_duration_sec: float
- throttle_time_source_type: rclpy.clock.Clock
- class rclpy.impl.rcutils_logger.LoggingFilter
Bases:
object
Base class for logging filters.
- classmethod initialize_context(context: RcutilsLoggerContext, **kwargs: Unpack[LoggingFilterArgs]) None
- params: ClassVar[LoggingFilterParams] = {}
Initialize the context of a logging call, e.g. declare variables needed for determining the log condition and add them to the context.
- static should_log(context: RcutilsLoggerContext) bool
- class rclpy.impl.rcutils_logger.LoggingFilterArgs
Bases:
TypedDict
- once: bool
- skip_first: bool
- throttle_duration_sec: float
- throttle_time_source_type: rclpy.clock.Clock
- class rclpy.impl.rcutils_logger.LoggingFilterParams
Bases:
TypedDict
- once: bool | None
- skip_first: bool | None
- throttle_duration_sec: float | None
- throttle_time_source_type: rclpy.clock.Clock
- class rclpy.impl.rcutils_logger.Once
Bases:
LoggingFilter
Ignore all log calls except the first one.
- classmethod initialize_context(context: RcutilsLoggerContext, **kwargs: Unpack[LoggingFilterArgs]) None
- params: ClassVar[LoggingFilterParams] = {'once': None}
Initialize the context of a logging call, e.g. declare variables needed for determining the log condition and add them to the context.
- static should_log(context: RcutilsLoggerContext) bool
- class rclpy.impl.rcutils_logger.OnceContext
Bases:
RcutilsLoggerContext
- filters: List[Literal['throttle', 'skip_first', 'once']]
- has_been_logged_once: bool
- name: str
- severity: LoggingSeverity
- class rclpy.impl.rcutils_logger.RcutilsLogger(name: str = '')
Bases:
object
- debug(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with DEBUG severity via :py:classmethod:RcutilsLogger.log:.
- error(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with ERROR severity via :py:classmethod:RcutilsLogger.log:.
- fatal(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with FATAL severity via :py:classmethod:RcutilsLogger.log:.
- get_child(name: str) RcutilsLogger
- get_effective_level() LoggingSeverity
- info(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with INFO severity via :py:classmethod:RcutilsLogger.log:.
- is_enabled_for(severity: int | LoggingSeverity) bool
- log(message: str, severity: int | LoggingSeverity, name: str | None = None, **kwargs: Unpack[LoggingFilterArgs]) bool
Log a message with the specified severity.
- The message will not be logged if:
the logger is not enabled for the message’s severity (the message severity is less than the level of the logger), or
a logging filter causes the message to be skipped.
Note
Logging filters will only be evaluated if the logger is enabled for the message’s severity.
- Parameters:
message – message to log.
severity – severity of the message.
name – name of the logger to use.
**kwargs – optional parameters for logging filters (see below).
- Keyword Arguments:
throttle_duration_sec (
float
) – Duration of the throttle interval for the :py:class:Throttle: filter.throttle_time_source_type (
str
) – Optional time source type for the :py:class:Throttle: filter (default ofRCUTILS_STEADY_TIME
)skip_first (
bool
) – If True, enable the :py:class:SkipFirst: filter.once (
bool
) – If True, enable the :py:class:Once: filter.
- Returns:
False if a filter caused the message to not be logged; True otherwise.
- Raises:
TypeError on invalid filter parameter combinations.
- Raises:
ValueError on invalid parameters values.
- set_level(level: int | LoggingSeverity) None
- warn(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with WARN severity via :py:classmethod:RcutilsLogger.log:.
Deprecated in favor of :py:classmethod:RcutilsLogger.warning:.
- warning(message: str, **kwargs: Unpack[LoggingArgs]) bool
Log a message with WARN severity via :py:classmethod:RcutilsLogger.log:.
- class rclpy.impl.rcutils_logger.RcutilsLoggerContext
Bases:
TypedDict
- filters: List[Literal['throttle', 'skip_first', 'once']]
- name: str
- severity: LoggingSeverity
- class rclpy.impl.rcutils_logger.SkipFirst
Bases:
LoggingFilter
Ignore the first log call but process all subsequent calls.
- classmethod initialize_context(context: RcutilsLoggerContext, **kwargs: Unpack[LoggingFilterArgs]) None
- params: ClassVar[LoggingFilterParams] = {'skip_first': None}
Initialize the context of a logging call, e.g. declare variables needed for determining the log condition and add them to the context.
- static should_log(context: RcutilsLoggerContext) bool
- class rclpy.impl.rcutils_logger.SkipFirstContext
Bases:
RcutilsLoggerContext
- filters: List[Literal['throttle', 'skip_first', 'once']]
- first_has_been_skipped: bool
- name: str
- severity: LoggingSeverity
- class rclpy.impl.rcutils_logger.Throttle
Bases:
LoggingFilter
Ignore log calls if the last call is not longer ago than the specified duration.
- classmethod initialize_context(context: RcutilsLoggerContext, **kwargs: Unpack[LoggingFilterArgs]) None
- params: ClassVar[LoggingFilterParams] = {'throttle_duration_sec': None, 'throttle_time_source_type': rclpy.clock.Clock}
Initialize the context of a logging call, e.g. declare variables needed for determining the log condition and add them to the context.
- static should_log(context: RcutilsLoggerContext) bool
- class rclpy.impl.rcutils_logger.ThrottleContext
Bases:
RcutilsLoggerContext
- filters: List[Literal['throttle', 'skip_first', 'once']]
- name: str
- severity: LoggingSeverity
- throttle_duration_sec: float
- throttle_last_logged: int
- throttle_time_source_type: rclpy.clock.Clock
- rclpy.impl.rcutils_logger.get_filters_from_kwargs(**kwargs: Unpack[LoggingFilterArgs]) List[Literal['throttle', 'skip_first', 'once']]
Determine which filters have had parameters specified in the given keyword arguments.
Returns the list of filters using the order specified by supported_filters.