MCPcopy Index your code
hub / github.com/FedML-AI/FedML / MLOpsFormatter

Class MLOpsFormatter

python/fedml/core/mlops/mlops_runtime_log.py:105–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103 self.logger = logging.getLogger(log_file_path)
104
105 class MLOpsFormatter(logging.Formatter):
106 converter = datetime.datetime.utcfromtimestamp
107
108 def __init__(self, fmt=None, datefmt=None, style='%', validate=True):
109 super().__init__(fmt, datefmt, style, validate)
110 self.ntp_offset = 0.0
111
112 # Here the `record` is a LogRecord object
113 def formatTime(self, record, datefmt=None):
114 log_time = record.created
115 if record.created is None:
116 log_time = time.time()
117
118 if self.ntp_offset is None:
119 self.ntp_offset = 0.0
120
121 log_ntp_time = int((log_time * 1000 + self.ntp_offset) / 1000.0)
122 ct = self.converter(log_ntp_time)
123 if datefmt:
124 s = ct.strftime(datefmt)
125 else:
126 s = ct.strftime("%a, %d %b %Y %H:%M:%S")
127 return s
128
129 format_str = MLOpsFormatter(fmt="[" + program_prefix + "] [%(asctime)s] [%(levelname)s] "
130 "[%(filename)s:%(lineno)d:%(funcName)s] %("

Callers 1

init_logsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected