MCPcopy Create free account
hub / github.com/KoljaB/RealtimeVoiceChat / formatTime

Method formatTime

code/logsetup.py:16–36  ·  view source on GitHub ↗

Formats the log record's creation time into MM:SS.cs format. Uses `time.localtime` to convert the record's creation timestamp and formats it as minutes, seconds, and centiseconds. The `datefmt` argument provided by the base class is ignored in this custom implementa

(self, record: logging.LogRecord, datefmt: Optional[str] = None)

Source from the content-addressed store, hash-verified

14 """
15
16 def formatTime(self, record: logging.LogRecord, datefmt: Optional[str] = None) -> str:
17 """
18 Formats the log record's creation time into MM:SS.cs format.
19
20 Uses `time.localtime` to convert the record's creation timestamp and
21 formats it as minutes, seconds, and centiseconds. The `datefmt` argument
22 provided by the base class is ignored in this custom implementation.
23
24 Args:
25 record: The log record whose creation time needs formatting.
26 datefmt: An optional date format string (ignored by this method).
27
28 Returns:
29 A string representing the formatted time (e.g., "59:23.18").
30 """
31 # Use localtime as originally intended, but locally within this formatter
32 now = time.localtime(record.created)
33 cs = int((record.created % 1) * 100) # centiseconds
34 # Format the time string as required
35 s = time.strftime("%M:%S", now) + f".{cs:02d}"
36 return s
37
38def setup_logging(level: int = logging.INFO) -> None:
39 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected