rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
Loading...
Searching...
No Matches
rosros.util.ThrottledLogger Class Reference

Logger wrapper with support for throttling logged messages per call site. More...

Inheritance diagram for rosros.util.ThrottledLogger:
Inheritance graph

Public Member Functions

 __init__ (self, logger)
 Creates a wrapper logger around given logger instance, providing support for throttling.
 
 debug (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `DEBUG`.
 
 error (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `ERROR`.
 
 fatal (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `FATAL`.
 
 info (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `INFO`.
 
 log (self, level, msg, *args, **kwargs)
 Logs `msg % args` with given severity.
 
 warn (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `WARNING`.
 
 warning (self, msg, *args, **kwargs)
 Logs `msg % args` with severity `WARN`.
 

Protected Member Functions

 _extract_args (cls, kwargs)
 Drops throttle parameters from kwargs and returns as dict.
 
 _is_throttled (cls, msg, once=False, throttle=None, throttle_identical=False)
 Returns whether message should be skipped.
 

Static Protected Attributes

dict _HASHES
 Caller IDs and log message hashes for throttling by identical text.
 
list _KEYWORDS
 
 _ONCES
 Caller IDs registered for throttling by once-only.
 
dict _TIMES
 Caller IDs and last timestamps for throttling by time.
 

Detailed Description

Logger wrapper with support for throttling logged messages per call site.

Logging methods (`debug()`, `info()`, etc) accept additional keyword arguments:

  • `__once__`: whether to log only once from call site
  • `__throttle__`: seconds to skip logging from call site for
  • `__throttle_identical__`: whether to skip logging identical consecutive texts from call site (given log message excluding formatting arguments). Combines with `__throttle__` to skip a duplicate for a period.

Definition at line 38 of file util.py.

Constructor & Destructor Documentation

◆ __init__()

rosros.util.ThrottledLogger.__init__ (   self,
  logger 
)

Creates a wrapper logger around given logger instance, providing support for throttling.

Parameters
`logging.Logger`to wrap

Definition at line 69 of file util.py.

Member Function Documentation

◆ _extract_args()

rosros.util.ThrottledLogger._extract_args (   cls,
  kwargs 
)
protected

Drops throttle parameters from kwargs and returns as dict.

Definition at line 144 of file util.py.

◆ _is_throttled()

rosros.util.ThrottledLogger._is_throttled (   cls,
  msg,
  once = False,
  throttle = None,
  throttle_identical = False 
)
protected

Returns whether message should be skipped.

Definition at line 152 of file util.py.

◆ debug()

rosros.util.ThrottledLogger.debug (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `DEBUG`.

To pass exception information, use the keyword argument `exc_info=True`.

Parameters
__once__whether to log only once from call site
__throttle__seconds to skip logging from call site for
__throttle_identical__whether to skip identical consecutive texts from call site

Definition at line 87 of file util.py.

◆ error()

rosros.util.ThrottledLogger.error (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `ERROR`.

The arguments are interpreted as for `debug()`.

Definition at line 119 of file util.py.

◆ fatal()

rosros.util.ThrottledLogger.fatal (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `FATAL`.

The arguments are interpreted as for `debug()`.

Definition at line 127 of file util.py.

◆ info()

rosros.util.ThrottledLogger.info (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `INFO`.

The arguments are interpreted as for `debug()`.

Definition at line 95 of file util.py.

◆ log()

rosros.util.ThrottledLogger.log (   self,
  level,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with given severity.

The arguments are interpreted as for `debug()`.

Definition at line 135 of file util.py.

◆ warn()

rosros.util.ThrottledLogger.warn (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `WARNING`.

The arguments are interpreted as for `debug()`.

Definition at line 111 of file util.py.

◆ warning()

rosros.util.ThrottledLogger.warning (   self,
  msg,
args,
**  kwargs 
)

Logs `msg % args` with severity `WARN`.

The arguments are interpreted as for `debug()`.

Definition at line 103 of file util.py.

Member Data Documentation

◆ _HASHES

rosros.util.ThrottledLogger._HASHES
staticprotected

Caller IDs and log message hashes for throttling by identical text.

Definition at line 61 of file util.py.

◆ _KEYWORDS

rosros.util.ThrottledLogger._KEYWORDS
staticprotected

Definition at line 43 of file util.py.

◆ _ONCES

rosros.util.ThrottledLogger._ONCES
staticprotected

Caller IDs registered for throttling by once-only.

Definition at line 49 of file util.py.

◆ _TIMES

rosros.util.ThrottledLogger._TIMES
staticprotected

Caller IDs and last timestamps for throttling by time.

Definition at line 55 of file util.py.


The documentation for this class was generated from the following file: