MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / format

Method format

plain2code_logger.py:30–54  ·  view source on GitHub ↗
(self, record)

Source from the content-addressed store, hash-verified

28 self.run_state = run_state
29
30 def format(self, record):
31 # Calculate elapsed time the same way as LoggingHandler does for the TUI
32 try:
33 offset_seconds = self.run_state.render_time_accumulated + int(
34 time.monotonic() - self.run_state.last_render_start_timestamp
35 )
36 except Exception:
37 # If RunState is not available or there's any error, default to 00:00:00
38 offset_seconds = 0
39
40 hours = offset_seconds // 3600
41 minutes = (offset_seconds % 3600) // 60
42 seconds = offset_seconds % 60
43 elapsed_time = f"[{hours:02d}:{minutes:02d}:{seconds:02d}]"
44
45 # Add elapsed_time to the record so it can be used in the format string
46 record.elapsed_time = elapsed_time
47
48 # Handle multi-line messages with proper indentation
49 original_message = record.getMessage()
50 indent = " " * len(elapsed_time + " ")
51 modified_message = original_message.replace("\n", "\n" + indent)
52 record.msg = modified_message
53
54 return super().format(record)
55
56
57class LoggingHandler(logging.Handler):

Callers

nothing calls this directly

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected