Skip to content

Commit ec072c2

Browse files
committed
Add disable logging based on debug state
1 parent a243257 commit ec072c2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pyaddons/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ class logger:
99
file = None
1010
timeWritten = False
1111
defaultAction = ""
12+
debugMode = False
1213

13-
def __init__(self, filePath="logger.log",default="l"):
14+
def __init__(self, filePath="logger.log",default="l",debug=False):
1415
self.filePath = filePath
1516
self.defaultAction = default
17+
self.debugMode = debug
1618

1719
def openFile(self,mode="a"):
1820
self.file = open(self.filePath, mode)
@@ -25,13 +27,16 @@ def log(self,statment,code=None):
2527
code = self.defaultAction
2628
printTrue = False
2729
logTrue = False
30+
onlyDebug = False
2831
typeAdded = False
2932
printStatment = ""
3033
for char in code:
3134
if char == "p":
3235
printTrue = True
3336
elif char == "l":
3437
logTrue = True
38+
elif char == 'd':
39+
onlyDebug = True
3540
elif char == "e":
3641
statment = "[ERROR]\t" + statment
3742
typeAdded = True
@@ -51,6 +56,10 @@ def log(self,statment,code=None):
5156
printTrue = True
5257
else:
5358
logTrue = True
59+
60+
if onlyDebug and not self.debugMode:
61+
printTrue = False
62+
logTrue = False
5463

5564
if logTrue:
5665
if not self.timeWritten:

0 commit comments

Comments
 (0)