MCPcopy Create free account
hub / github.com/SegmentationBLWX/cssegmentation / LocalLoggerHandle

Class LocalLoggerHandle

csseg/modules/utils/logger.py:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11'''LocalLoggerHandle'''
12class LocalLoggerHandle():
13 def __init__(self, logfilepath):
14 self.logfilepath = logfilepath
15 '''log'''
16 def log(self, message, level='INFO', endwithnewline=True):
17 message = f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {level} {message}'
18 print(message)
19 if not message.endswith('\n') and endwithnewline:
20 message = message + '\n'
21 with open(self.logfilepath, 'a') as fp:
22 fp.write(message)
23 '''debug'''
24 def debug(self, message, endwithnewline=True):
25 self.log(message, 'DEBUG', endwithnewline)
26 '''info'''
27 def info(self, message, endwithnewline=True):
28 self.log(message, 'INFO', endwithnewline)
29 '''warning'''
30 def warning(self, message, endwithnewline=True):
31 self.log(message, 'WARNING', endwithnewline)
32 '''error'''
33 def error(self, message, endwithnewline=True):
34 self.log(message, 'ERROR', endwithnewline)
35
36
37'''LoggerHandleBuilder'''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected