opencast / pyCA

Python Capture Agent for Opencast
GNU Lesser General Public License v3.0
50 stars 40 forks source link

Clear logging handler when initializing the logger #529

Closed mtneug closed 5 months ago

mtneug commented 6 months ago

This patch clears the root logging handlers when initializing the logger.

This might be considered a quickfix. The root problem is that the configuration might be loaded twice when starting up:

  1. When importing the Prometheus collectors, the configuration is loaded implicitly when accessing configuration values.
  2. __main__.py calls config.update_configuration explicitly.

The result is that the list of root logging handlers contains duplicate entries. Each line is thus logged twice.

Since the config can be loaded lazily, one might remove the explicit call in __main__.py. However, my reasoning for this approach was that resetting the logger handlers during initialization makes sense anyway.

lkiesow commented 5 months ago

Rebased on current main