[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-taler-util] 11/51: Towards a usable solution for #44
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-taler-util] 11/51: Towards a usable solution for #4453. |
Date: |
Mon, 23 Sep 2019 22:02:02 +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 47409eb122caf564c2e3facfce229caa14d78eae
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Feb 4 18:01:23 2019 +0100
Towards a usable solution for #4453.
---
python/log/gnunet_log.py | 47 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/python/log/gnunet_log.py b/python/log/gnunet_log.py
index 91fe852..32b49a7 100755
--- a/python/log/gnunet_log.py
+++ b/python/log/gnunet_log.py
@@ -3,27 +3,62 @@
# GNUNET_FORCE_LOG format [component];[file];[function];[from line [to
line]];loglevel
import os
+import logging
class GnunetLogger:
+
+ ERROR = logging.ERROR
+ WARNING = logging.WARNING
+ INFO = logging.INFO
+ DEBUG = logging.DEBUG
- def __init__(self, component):
+ def __init__(self, component, loglevel):
self.component = component
+ # loglevel set at "compile time".
+ self.loglevel = loglevel
+ logging.basicConfig(level=loglevel)
+ self.logger = logging.getLogger(component)
- def wmn(self):
- print(self.component)
+ self.level_map = {"ERROR": logging.ERROR,
+ "WARNING": logging.WARNING,
+ "INFO": logging.INFO,
+ "DEBUG": logging.DEBUG}
- def log(self):
+ def __internal_log(self, message, message_loglevel, ruling_loglevel):
+
+ if not ruling_loglevel:
+ print("Garbage loglevel fetched from env, not logging")
+ self.logger.setLevel(level=ruling_loglevel)
+
+ if GnunetLogger.ERROR == message_loglevel:
+ fn = self.logger.error
+ if GnunetLogger.WARNING == message_loglevel:
+ fn = self.logger.warning
+ if GnunetLogger.INFO == message_loglevel:
+ fn = self.logger.info
+ if GnunetLogger.DEBUG == message_loglevel:
+ fn = self.logger.debug
+ fn(message)
+
+ def log(self, message, loglevel):
if not os.environ.get("GNUNET_FORCE_LOG"):
+ self.__internal_log(message, loglevel, self.loglevel)
return
gfl = os.environ.get("GNUNET_FORCE_LOG")
gfl_split = gfl.split("/")
for component in gfl_split:
- gfl_split_split = gfl_split.split(";")
- if 4 != len(gfl_split_split):
+ gfl_split_split = component.split(";")
+ if 5 != len(gfl_split_split):
print("warning: GNUNET_FORCE_LOG is malformed")
+ self.__internal_log(message, loglevel, self.loglevel)
return
# if component chunk is not empty and different from
# this component name, then abort, otherwise further
# proceed.
if gfl_split_split[0] and self.component != gfl_split_split[0]:
return
+
+ # for simplicity, and for now, we supersede the check
+ # of the 'file', 'function' and 'from line [to line]' bits.
+ # Just check the loglevel.
+ self.__internal_log(message, loglevel,
self.level_map.get(gfl_split_split[4]))
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-taler-util] 03/51: amount version 0.1. Basically has some new exceptions, (continued)
- [GNUnet-SVN] [taler-taler-util] 03/51: amount version 0.1. Basically has some new exceptions, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 10/51: Very first draft for solving #4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 05/51: First commit for #4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 02/51: adding amount lib, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 04/51: add talerconfig and linted amount, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 06/51: remove old config, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 07/51: Update "config" module (with one that implements @INLINE@)., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 14/51: log test, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 12/51: make map static, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 25/51: 4453. Parsing line interval., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 11/51: Towards a usable solution for #4453.,
gnunet <=
- [GNUnet-SVN] [taler-taler-util] 13/51: Give loglevels dedicate class + test., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 16/51: Updating Amount from bank., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 19/51: Parsing GNUNET_FORCE_LOGFILE., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 26/51: 4453. Check against further fields (filename, func, lineno), gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 17/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 24/51: fix filename extraction., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 18/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 20/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 22/51: 4453, use regex., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 15/51: Update amount., gnunet, 2019/09/23