public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2024-07-30 11:08 Andreas K. Hüttel
  2024-08-09 19:34 ` [gentoo-commits] proj/catalyst:dilfridge/qcow2 " Andreas K. Hüttel
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas K. Hüttel @ 2024-07-30 11:08 UTC (permalink / raw
  To: gentoo-commits

commit:     27035bc1a25e57fc3127db865b999acf15bd1697
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jul 29 22:24:44 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Tue Jul 30 11:08:12 2024 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=27035bc1

log: hide our functions and include line numbers

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 catalyst/log.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/catalyst/log.py b/catalyst/log.py
index ee124392..fb852f2f 100644
--- a/catalyst/log.py
+++ b/catalyst/log.py
@@ -20,6 +20,11 @@ class CatalystLogger(logging.Logger):
 
     def _log(self, level, msg, args, **kwargs):
         """If given a multiline message, split it"""
+
+        # Increment stacklevel to hide this function call
+        stacklevel = kwargs.get("stacklevel", 1)
+        kwargs["stacklevel"] = stacklevel + 1
+
         # We have to interpolate it first in case they spread things out
         # over multiple lines like: Bad Thing:\n%s\nGoodbye!
         msg %= args
@@ -44,11 +49,21 @@ logging.addLevelName(NOTICE, 'NOTICE')
 # The API we expose to consumers.
 def notice(msg, *args, **kwargs):
     """Log a notice message"""
+
+    # Increment stacklevel to hide this function call
+    stacklevel = kwargs.get("stacklevel", 1)
+    kwargs["stacklevel"] = stacklevel + 1
+
     logger.log(NOTICE, msg, *args, **kwargs)
 
 
 def critical(msg, *args, **kwargs):
     """Log a critical message and then exit"""
+
+    # Increment stacklevel to hide this function call
+    stacklevel = kwargs.get("stacklevel", 1)
+    kwargs["stacklevel"] = stacklevel + 1
+
     status = kwargs.pop('status', 1)
     logger.critical(msg, *args, **kwargs)
     sys.exit(status)
@@ -110,7 +125,7 @@ def setup_logging(level, output=None, debug=False, color=None):
     # The good stuff.
     fmt = '%(asctime)s: %(levelname)-8s: '
     if debug:
-        fmt += '%(filename)s:%(funcName)s: '
+        fmt += '%(filename)s:%(funcName)s:%(lineno)d: '
     fmt += '%(message)s'
 
     # Figure out where to send the log output.


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/catalyst:dilfridge/qcow2 commit in: catalyst/
  2024-07-30 11:08 [gentoo-commits] proj/catalyst:master commit in: catalyst/ Andreas K. Hüttel
@ 2024-08-09 19:34 ` Andreas K. Hüttel
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas K. Hüttel @ 2024-08-09 19:34 UTC (permalink / raw
  To: gentoo-commits

commit:     27035bc1a25e57fc3127db865b999acf15bd1697
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jul 29 22:24:44 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Tue Jul 30 11:08:12 2024 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=27035bc1

log: hide our functions and include line numbers

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 catalyst/log.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/catalyst/log.py b/catalyst/log.py
index ee124392..fb852f2f 100644
--- a/catalyst/log.py
+++ b/catalyst/log.py
@@ -20,6 +20,11 @@ class CatalystLogger(logging.Logger):
 
     def _log(self, level, msg, args, **kwargs):
         """If given a multiline message, split it"""
+
+        # Increment stacklevel to hide this function call
+        stacklevel = kwargs.get("stacklevel", 1)
+        kwargs["stacklevel"] = stacklevel + 1
+
         # We have to interpolate it first in case they spread things out
         # over multiple lines like: Bad Thing:\n%s\nGoodbye!
         msg %= args
@@ -44,11 +49,21 @@ logging.addLevelName(NOTICE, 'NOTICE')
 # The API we expose to consumers.
 def notice(msg, *args, **kwargs):
     """Log a notice message"""
+
+    # Increment stacklevel to hide this function call
+    stacklevel = kwargs.get("stacklevel", 1)
+    kwargs["stacklevel"] = stacklevel + 1
+
     logger.log(NOTICE, msg, *args, **kwargs)
 
 
 def critical(msg, *args, **kwargs):
     """Log a critical message and then exit"""
+
+    # Increment stacklevel to hide this function call
+    stacklevel = kwargs.get("stacklevel", 1)
+    kwargs["stacklevel"] = stacklevel + 1
+
     status = kwargs.pop('status', 1)
     logger.critical(msg, *args, **kwargs)
     sys.exit(status)
@@ -110,7 +125,7 @@ def setup_logging(level, output=None, debug=False, color=None):
     # The good stuff.
     fmt = '%(asctime)s: %(levelname)-8s: '
     if debug:
-        fmt += '%(filename)s:%(funcName)s: '
+        fmt += '%(filename)s:%(funcName)s:%(lineno)d: '
     fmt += '%(message)s'
 
     # Figure out where to send the log output.


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-09 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 11:08 [gentoo-commits] proj/catalyst:master commit in: catalyst/ Andreas K. Hüttel
2024-08-09 19:34 ` [gentoo-commits] proj/catalyst:dilfridge/qcow2 " Andreas K. Hüttel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox