[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-taler-util] 13/51: Give loglevels dedicate class + t
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-taler-util] 13/51: Give loglevels dedicate class + test. |
Date: |
Mon, 23 Sep 2019 22:02:04 +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 2ed84bcd9fb1ae41e3c667c5b3735f5a756faca8
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Feb 4 19:12:14 2019 +0100
Give loglevels dedicate class + test.
---
python/log/gnunet_log.py | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/python/log/gnunet_log.py b/python/log/gnunet_log.py
index 6ab88ee..ee2dc12 100755
--- a/python/log/gnunet_log.py
+++ b/python/log/gnunet_log.py
@@ -5,30 +5,42 @@
import os
import logging
+class GnunetLogLevel:
+
+ def __init__(self, nativeLoggingLevel, stringification):
+ self.native_logging_level = nativeLoggingLevel
+ self.stringification = stringification
+ def getNativeLevel(self):
+ return self.native_logging_level
+ def __str__(self):
+ return self.stringification
+
+
class GnunetLogger:
- ERROR = logging.ERROR
- WARNING = logging.WARNING
- INFO = logging.INFO
- DEBUG = logging.DEBUG
+ ERROR = GnunetLogLevel(logging.ERROR, "ERROR")
+ WARNING = GnunetLogLevel(logging.WARNING, "WARNING")
+ INFO = GnunetLogLevel(logging.INFO, "INFO")
+ DEBUG = GnunetLogLevel(logging.DEBUG, "DEBUG")
- level_map = {"ERROR": logging.ERROR,
- "WARNING": logging.WARNING,
- "INFO": logging.INFO,
- "DEBUG": logging.DEBUG}
+ level_map = {"ERROR": ERROR,
+ "WARNING": WARNING,
+ "INFO": INFO,
+ "DEBUG": DEBUG}
def __init__(self, component, loglevel):
+ print("Log setup, component: %s, level: %s" % (component,
str(loglevel)))
self.component = component
# loglevel set at "compile time".
self.loglevel = loglevel
- logging.basicConfig(level=loglevel)
+ logging.basicConfig(level=loglevel.getNativeLevel())
self.logger = logging.getLogger(component)
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)
+ self.logger.setLevel(level=ruling_loglevel.getNativeLevel())
if GnunetLogger.ERROR == message_loglevel:
fn = self.logger.error
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-taler-util] 10/51: Very first draft for solving #4453., (continued)
- [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, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 13/51: Give loglevels dedicate class + test.,
gnunet <=
- [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
- [GNUnet-SVN] [taler-taler-util] 21/51: 4453., gnunet, 2019/09/23