MCPcopy Create free account
hub / github.com/LabSound/LabSound / LabSoundLog

Function LabSoundLog

src/extended/LabSound.cpp:259–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257
258
259void LabSoundLog(int level, const char *file, int line, const char *fmt, ...) {
260 if (level < L.level) {
261 return;
262 }
263
264 /* Acquire lock */
265 lock();
266
267 /* Get current time */
268 time_t t = time(NULL);
269 struct tm *lt = localtime(&t);
270
271 /* Log to stderr */
272 if (!L.quiet) {
273 va_list args;
274 char buf[16];
275 buf[strftime(buf, sizeof(buf), "%H:%M:%S", lt)] = '\0';
276#ifdef LOG_USE_COLOR
277 fprintf(
278 stderr, "%s %s%-5s\x1b[0m \x1b[90m%s:%d:\x1b[0m ",
279 buf, level_colors[level], level_names[level], file, line);
280#else
281 fprintf(stderr, "%s %-5s %s:%d: ", buf, level_names[level], file, line);
282#endif
283 va_start(args, fmt);
284 vfprintf(stderr, fmt, args);
285 va_end(args);
286 fprintf(stderr, "\n");
287 fflush(stderr);
288 }
289
290 /* Log to file */
291 if (L.fp) {
292 va_list args;
293 char buf[32];
294 buf[strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", lt)] = '\0';
295 fprintf(L.fp, "%s %-5s %s:%d: ", buf, level_names[level], file, line);
296 va_start(args, fmt);
297 vfprintf(L.fp, fmt, args);
298 va_end(args);
299 fprintf(L.fp, "\n");
300 fflush(L.fp);
301 }
302
303 /* Release lock */
304 unlock();
305}
306
307void LabSoundAssertLog(const char * file_, int line, const char * function_, const char * assertion_)
308{

Callers

nothing calls this directly

Calls 2

lockFunction · 0.85
unlockFunction · 0.85

Tested by

no test coverage detected