MCPcopy Create free account
hub / github.com/crownengine/crown / console_log

Function console_log

src/device/log.cpp:44–75  ·  view source on GitHub ↗

Sends a log message to all clients.

Source from the content-addressed store, hash-verified

42
43 /// Sends a log message to all clients.
44 static void console_log(LogSeverity::Enum sev, System system, const char *msg)
45 {
46#if !CROWN_LOG_TO_CONSOLE
47 CE_UNUSED_3(sev, system, msg);
48#else
49 if (!console_server())
50 return;
51
52 const char *severity_map[] = { "info", "warning", "error", "debug" };
53 CE_STATIC_ASSERT(countof(severity_map) == LogSeverity::COUNT);
54
55 TempAllocator4096 ta;
56 StringStream ss(ta);
57
58 ss << "{\"type\":\"message\",\"severity\":\"";
59 ss << severity_map[sev];
60 ss << "\",\"system\":\"";
61 ss << system.name;
62 ss << "\",\"message\":\"";
63
64 // Sanitize msg
65 const char *ch = msg;
66 for (; *ch; ch++) {
67 if (*ch == '"' || *ch == '\\')
68 ss << "\\";
69 ss << *ch;
70 }
71 ss << "\"}";
72
73 console_server()->broadcast(string_stream::c_str(ss));
74#endif // if !CROWN_LOG_TO_CONSOLE
75 }
76
77 void vlogx(LogSeverity::Enum sev, System system, const char *format, va_list args)
78 {

Callers 1

vlogxFunction · 0.85

Calls 2

console_serverFunction · 0.85
broadcastMethod · 0.80

Tested by

no test coverage detected