MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / event

Method event

src/mcp_client/logger.py:905–931  ·  view source on GitHub ↗

Log a structured event for machine parsing.

(
        self,
        event_type: str,
        data: dict,
        *,
        timestamp: str | None = None,
        to_stdout: bool = False,
    )

Source from the content-addressed store, hash-verified

903 self._console.print(Rule(style=color or self._PAL_GREEN))
904
905 def event(
906 self,
907 event_type: str,
908 data: dict,
909 *,
910 timestamp: str | None = None,
911 to_stdout: bool = False,
912 ):
913 """
914 Log a structured event for machine parsing.
915 """
916 with self._lock:
917 payload = {
918 "type": event_type,
919 "timestamp": timestamp or datetime.now().isoformat(),
920 "data": data,
921 }
922 line = (
923 f"{EVENT_START}{json.dumps(payload, ensure_ascii=False)}{EVENT_END}\n"
924 )
925 self._append_line(
926 line,
927 log_path=self.event_log_path,
928 host_path=self.host_event_log_path,
929 to_stdout=to_stdout,
930 )
931 self._render_event(event_type, data, timestamp=payload["timestamp"])
932
933 def log_event(self, logger, event_type: str, data: Dict[str, Any]):
934 event_fn = getattr(logger, "event", None)

Callers 9

runMethod · 0.95
executeMethod · 0.80
runMethod · 0.80
run_interactiveMethod · 0.80
_setupMethod · 0.80
_run_plan_modeMethod · 0.80
_inner_loopMethod · 0.80

Calls 2

_append_lineMethod · 0.95
_render_eventMethod · 0.95

Tested by

no test coverage detected