Project

Profile

Help

Issue #8499

Updated by bmbouter 6 months ago

## Problem

Currently warnings are implemented with `warnings.warn` which is not being shown in the logs.

`#python` pointed me to [this interesting section of the docs](https://docs.python.org/3/howto/logging.html#when-to-use-logging) contrasting warning.warn() vs logging.warning() which suggests warning.warn is right, but then in the channel 3+ well-known python folks said that even though Python has DeprecatedWarning we shouldn't use it because in practice no one see's it. In order to see it users would have to run Python -Wall which is not practical or in some cases possible, e.g. we aren't in control of how the `/usr/bin/rq` binary calls Python.

Ultimately our goal with these warnings was to have both users AND developers see them. To do that, the devs in #python recommended we switch to logging.warning().

## Fix

1. Create a new logger that can be used by plugin writers Instead we should convert all usage to log at the warning level. `logging.warning`.
2. Port the existing usage to use this new deprecated logger.
3.
Update the [plugin writer docs](https://docs.pulpproject.org/pulpcore/plugins/plugin-writer/concepts/index.html#plugin-api-stability-and-deprecation-policy) also.

## Why another logger? Downside

It allows a system, e.g. a Downstreams will emit warnings and they would have to patch the downstream system, to disable the deprecation warnings while still retaining other normal application warnings. remove them. Unfortunately I think that is what we'll have to do.

Back