watcher#

All functions and features for logging the app

class src.tetue_generic.watcher.WatcherConfiguration(**data)[source]#

Configuration model for the watcher component.

This class inherits from Pydantic’s BaseModel and defines the configuration parameters for logging in the watcher component.

log_level#

The logging level to be used (e.g., “DEBUG”, “INFO”, “WARNING”).

Type:

str

log_file_path#

The file path where log files will be stored.

Type:

str | pathlib.Path

src.tetue_generic.watcher.init_logging(conf_watcher)[source]#

Initializes logging configuration for the application..

Parameters:
Return type:

None

Returns:

None

Note

  • This function modifies the global logger object from Loguru.

  • The ‘EXTDEBUG’ level is set to 9, between DEBUG (10) and INFO (20).

  • Log files are rotated when they reach 500 MB in size.

  • Console output is colorized for better readability.

Initialization function#

The initialization process is performed by the src.tetue_generic.watcher.init_logging() function. This function performs the following tasks:

Procedure for the initialization process#

  1. Removes any existing log handlers.

  2. Adds a custom log level ‘EXTDEBUG’.

  3. Configures file logging with rotation.

  4. Sets up console logging with color output

Log levels#

The following log levels are available:

  • TRACE

  • EXTDEBUG

  • DEBUG

  • INFO

  • SUCCESS

  • WARNING

  • ERROR

  • CRITICAL

Two Debug Levels for Optimized Logging Granularity

Our system employs two distinct debug levels:

  1. DEBUG: For general debugging information.

  2. EXTDEBUG: For more detailed, cyclically queried information.

The EXTDEBUG level is used for high-frequency logging events such as repeated API requests. This prevents the standard DEBUG log from being flooded with repetitive information while still allowing for deeper insight into system behavior when needed.

Example: While DEBUG logs general process steps, EXTDEBUG records every single API request with details. This enables precise troubleshooting without compromising the readability of standard logs.