summaryrefslogtreecommitdiff
path: root/cloudinit/log.py
diff options
context:
space:
mode:
authorBrett Holman <brett.holman@canonical.com>2023-02-24 08:00:44 -0700
committerGitHub <noreply@github.com>2023-02-24 08:00:44 -0700
commit6100fda632f63605981636c0900e1e0b8b354979 (patch)
treedab05196ac0cc299acd0c672053e3506c0ade213 /cloudinit/log.py
parent46fcd03187d70f405c748f7a6cfdb02ecb8c6ee7 (diff)
downloadcloud-init-git-6100fda632f63605981636c0900e1e0b8b354979.tar.gz
log: Add standardized deprecation tooling (SC-1312) (#2026)
- Add deprecation log level - Add deprecation utilities for structured format and messaging - Update existing deprecation log sites, add deprecated versions
Diffstat (limited to 'cloudinit/log.py')
-rw-r--r--cloudinit/log.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/cloudinit/log.py b/cloudinit/log.py
index f40201bb..d9912a50 100644
--- a/cloudinit/log.py
+++ b/cloudinit/log.py
@@ -63,6 +63,16 @@ def flushLoggers(root):
flushLoggers(root.parent)
+def defineDeprecationLogger(lvl=35):
+ logging.addLevelName(lvl, "DEPRECATED")
+
+ def deprecated(self, message, *args, **kwargs):
+ if self.isEnabledFor(lvl):
+ self._log(lvl, message, args, **kwargs)
+
+ logging.Logger.deprecated = deprecated
+
+
def setupLogging(cfg=None):
# See if the config provides any logging conf...
if not cfg:
@@ -83,6 +93,7 @@ def setupLogging(cfg=None):
log_cfgs.append("\n".join(cfg_str))
else:
log_cfgs.append(str(a_cfg))
+ defineDeprecationLogger()
# See if any of them actually load...
am_tried = 0