Files
2024-03-29 10:49:35 -07:00

43 lines
1.1 KiB
C++

// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
// Log - implemented using stderr.
#include "log.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
namespace wvutil {
LogPriority g_cutoff = CDM_LOG_INFO;
void InitLogging() {}
void Log(const char* file, const char* function, int line, LogPriority level,
const char* fmt, ...) {
const char* severities[] = {"ERROR", "WARN", "INFO", "DEBUG", "VERBOSE"};
if (level < 0 || level >= static_cast<LogPriority>(sizeof(severities) /
sizeof(severities[0]))) {
fprintf(stderr, "[FATAL:%s(%d)] Invalid log priority level: %d\n", file,
line, level);
return;
}
if (level > g_cutoff) return;
fprintf(stderr, "[%s:%s(%d):%s] ", severities[level], file, line, function);
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
putc('\n', stderr);
fflush(stderr);
}
} // namespace wvutil