utils: Small optimization in pretty()
patch 95e72ac9b26835162b8ba997c5ff99edfd5d464e
Author: E. Bosch <presidev@AT@gmail.com>
Date: Fri Aug 30 19:00:53 CEST 2024
* utils: Small optimization in pretty()
diff -rN -u old-irgramd/utils.py new-irgramd/utils.py
--- old-irgramd/utils.py 2024-10-23 06:38:23.466756545 +0200
+++ new-irgramd/utils.py 2024-10-23 06:38:23.466756545 +0200
@@ -43,6 +43,9 @@
desc = 1
brief = 2
+class LOGL:
+ debug = False
+
def chunks(iterable, n, fillvalue=None):
''' Return iterable consisting of a sequence of n-length chunks '''
args = [iter(iterable)] * n
@@ -224,6 +227,8 @@
def parse_loglevel(level):
levelu = level.upper()
+ if levelu == 'DEBUG':
+ LOGL.debug = True
if levelu == 'NONE':
l = None
elif levelu in ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'):
@@ -233,4 +238,4 @@
return l
def pretty(object):
- return object.stringify() if object else object
+ return object.stringify() if LOGL.debug and object else object