gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-taler-util] 23/51: fetch caller's metadata.


From: gnunet
Subject: [GNUnet-SVN] [taler-taler-util] 23/51: fetch caller's metadata.
Date: Mon, 23 Sep 2019 22:02:14 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository taler-util.

commit ef5fe40103b7656d38c0e2e538dc1d0147f83790
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Feb 6 18:28:35 2019 +0100

    fetch caller's metadata.
---
 python/log/gnunet_log.py | 6 ++++++
 python/log/test.py       | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/python/log/gnunet_log.py b/python/log/gnunet_log.py
index 1f619ff..55b5080 100755
--- a/python/log/gnunet_log.py
+++ b/python/log/gnunet_log.py
@@ -6,6 +6,7 @@ import os
 import re
 import logging
 import datetime
+import inspect
 
 class LogDefinition:
     def __init__(self, component, filename, function, loglevel, forced):
@@ -95,6 +96,11 @@ class GnunetLogger:
         self.loglevel = loglevel
 
     def log(self, message, message_loglevel):
+        caller_frame = inspect.stack()[1]
+
+        filename = inspect.getfile(caller_frame[0])
+        lineno = caller_frame.lineno
+        function = caller_frame.function
 
         # Ordinary case (level setup + nothing forced).
         if self.loglevel and self.no_forced_definitions:
diff --git a/python/log/test.py b/python/log/test.py
index 8467c51..763ef38 100755
--- a/python/log/test.py
+++ b/python/log/test.py
@@ -4,6 +4,9 @@ from gnunet_log import GnunetLogger as GL
 import os
 import sys
 
+# TODO
+import unittest
+
 # 1st test _without_ GNUNET_FORCE_LOG being defined.
 print("Testing with GNUNET_FORCE_LOG *unset*")
 if os.environ.get("GNUNET_FORCE_LOG"):
@@ -63,4 +66,3 @@ os.environ["GNUNET_FORCE_LOGFILE"] = 
"/tmp/{}-pid_[]-year_%Y-month_%m-day_%d.log
 gl = GL("gnunetish-python-logging")
 gl.log("I'm a ERROR message, and should go to 
/tmp/{}-[]-year_%Y-month_%m-day_%d.log", gl.ERROR)
 gl.log("I'm a DEBUG message, and should *not* go to 
/tmp/{}-pid_[]-year_%Y-month_%m-day_%d.log (& console)", gl.DEBUG)
-

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]