diff --git a/rclpy/rclpy/logging.py b/rclpy/rclpy/logging.py index d67e2259b..5f8d3f5e5 100644 --- a/rclpy/rclpy/logging.py +++ b/rclpy/rclpy/logging.py @@ -14,51 +14,53 @@ from pathlib import Path +from typing import Union from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy from rclpy.impl.logging_severity import LoggingSeverity -import rclpy.impl.rcutils_logger +from rclpy.impl.rcutils_logger import RcutilsLogger -_root_logger = rclpy.impl.rcutils_logger.RcutilsLogger() +_root_logger = RcutilsLogger() -def get_logger(name): +def get_logger(name: str) -> RcutilsLogger: if not name: raise ValueError('Logger name must not be empty.') return _root_logger.get_child(name) -def initialize(): - return _rclpy.rclpy_logging_initialize() +def initialize() -> None: + _rclpy.rclpy_logging_initialize() -def shutdown(): - return _rclpy.rclpy_logging_shutdown() +def shutdown() -> None: + _rclpy.rclpy_logging_shutdown() -def clear_config(): +def clear_config() -> None: """Clear the configuration of the logging system, e.g. logger levels.""" shutdown() initialize() -def set_logger_level(name, level, detailed_error=False): +def set_logger_level(name: str, level: Union[int, LoggingSeverity], + detailed_error: bool = False) -> None: level = LoggingSeverity(level) - return _rclpy.rclpy_logging_set_logger_level(name, level, detailed_error) + _rclpy.rclpy_logging_set_logger_level(name, level, detailed_error) -def get_logger_effective_level(name): +def get_logger_effective_level(name: str) -> LoggingSeverity: logger_level = _rclpy.rclpy_logging_get_logger_effective_level(name) return LoggingSeverity(logger_level) -def get_logger_level(name): +def get_logger_level(name: str) -> LoggingSeverity: logger_level = _rclpy.rclpy_logging_get_logger_level(name) return LoggingSeverity(logger_level) -def get_logging_severity_from_string(log_severity): +def get_logging_severity_from_string(log_severity: str) -> LoggingSeverity: return LoggingSeverity( _rclpy.rclpy_logging_severity_level_from_string(log_severity))