MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_log

Function cbm_log

src/foundation/log.c:208–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void cbm_log(CBMLogLevel level, const char *msg, ...) {
209 if (level < g_log_level) {
210 return;
211 }
212
213 char line_buf[CBM_SZ_4K];
214 size_t pos = 0;
215 va_list args;
216 va_start(args, msg);
217
218 if (g_log_format == CBM_LOG_FORMAT_JSON) {
219 append_raw(line_buf, sizeof(line_buf), &pos, "{\"level\":");
220 append_json_string(line_buf, sizeof(line_buf), &pos, level_str(level));
221 append_raw(line_buf, sizeof(line_buf), &pos, ",\"event\":");
222 append_json_string(line_buf, sizeof(line_buf), &pos, msg ? msg : "");
223 for (;;) {
224 const char *key = va_arg(args, const char *);
225 if (!key) {
226 break;
227 }
228 const char *val = va_arg(args, const char *);
229 append_char(line_buf, sizeof(line_buf), &pos, ',');
230 append_json_string(line_buf, sizeof(line_buf), &pos, key);
231 append_char(line_buf, sizeof(line_buf), &pos, ':');
232 append_json_string(line_buf, sizeof(line_buf), &pos, val ? val : "");
233 }
234 append_char(line_buf, sizeof(line_buf), &pos, '}');
235 } else {
236 append_raw(line_buf, sizeof(line_buf), &pos, "level=");
237 append_text_atom(line_buf, sizeof(line_buf), &pos, level_str(level));
238 append_raw(line_buf, sizeof(line_buf), &pos, " msg=");
239 append_text_atom(line_buf, sizeof(line_buf), &pos, msg ? msg : "");
240 for (;;) {
241 const char *key = va_arg(args, const char *);
242 if (!key) {
243 break;
244 }
245 const char *val = va_arg(args, const char *);
246 append_char(line_buf, sizeof(line_buf), &pos, ' ');
247 append_text_atom(line_buf, sizeof(line_buf), &pos, key);
248 append_char(line_buf, sizeof(line_buf), &pos, '=');
249 append_text_atom(line_buf, sizeof(line_buf), &pos, val ? val : "");
250 }
251 }
252 va_end(args);
253
254 finish_line(line_buf, sizeof(line_buf), pos);
255 emit_line(line_buf);
256}
257
258void cbm_log_int(CBMLogLevel level, const char *msg, const char *key, int64_t value) {
259 char value_buf[CBM_SZ_32];

Callers 3

cbm_log_intFunction · 0.85
cbm_log_mcp_requestFunction · 0.85
cbm_log_http_requestFunction · 0.85

Calls 7

append_rawFunction · 0.85
level_strFunction · 0.85
append_charFunction · 0.85
append_text_atomFunction · 0.85
finish_lineFunction · 0.85
emit_lineFunction · 0.85
append_json_stringFunction · 0.70

Tested by

no test coverage detected