MCPcopy Create free account
hub / github.com/MemTensor/MemOS / emit

Method emit

src/memos/log.py:92–119  ·  view source on GitHub ↗

Process log records of INFO or ERROR level (non-blocking)

(self, record)

Source from the content-addressed store, hash-verified

90 atexit.register(self._cleanup)
91
92 def emit(self, record):
93 """Process log records of INFO or ERROR level (non-blocking)"""
94 if os.getenv("CUSTOM_LOGGER_URL") is None or self._is_shutting_down.is_set():
95 return
96
97 # Only process INFO and ERROR level logs
98 if record.levelno < logging.INFO: # Skip DEBUG and lower
99 return
100
101 try:
102 trace_id = get_current_trace_id() or "trace-id"
103 api_path = get_current_api_path()
104 env = get_current_env()
105 user_type = get_current_user_type()
106 user_name = get_current_user_name()
107 if api_path is not None:
108 self._executor.submit(
109 self._send_log_sync,
110 record.getMessage(),
111 trace_id,
112 api_path,
113 env,
114 user_type,
115 user_name,
116 )
117 except Exception as e:
118 if not self._is_shutting_down.is_set():
119 print(f"Error sending log: {e}")
120
121 def _send_log_sync(self, message, trace_id, api_path, env, user_type, user_name):
122 """Send log message synchronously in a separate thread"""

Callers

nothing calls this directly

Calls 6

get_current_trace_idFunction · 0.90
get_current_api_pathFunction · 0.90
get_current_envFunction · 0.90
get_current_user_typeFunction · 0.90
get_current_user_nameFunction · 0.90
submitMethod · 0.80

Tested by

no test coverage detected