MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / Logger

Class Logger

rat-sql-gap/seq2struct/commands/train.py:54–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54class Logger:
55 def __init__(self, log_path=None, reopen_to_flush=False):
56 self.log_file = None
57 self.reopen_to_flush = reopen_to_flush
58 if log_path is not None:
59 os.makedirs(os.path.dirname(log_path), exist_ok=True)
60 self.log_file = open(log_path, 'a+')
61
62 def log(self, msg):
63 formatted = '[{}] {}'.format(
64 datetime.datetime.now().replace(microsecond=0).isoformat(),
65 msg)
66 print(formatted)
67 if self.log_file:
68 self.log_file.write(formatted + '\n')
69 if self.reopen_to_flush:
70 log_path = self.log_file.name
71 self.log_file.close()
72 self.log_file = open(log_path, 'a+')
73 else:
74 self.log_file.flush()
75
76class Trainer:
77 def __init__(self, logger, config):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected