52#define DEBUG_BUF_SIZE 2048
56void log_msg(
const int priority,
const char *fmt, ...)
69static void log_init(
void)
78 if (isatty(fileno(stderr)))
85 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
89 for (i = 0; i < COUNT_OF(terms); i++)
92 if (0 == strcmp(terms[i], term))
102void log_msg(
const int priority,
const char *fmt, ...)
104 char DebugBuffer[DEBUG_BUF_SIZE];
106 static bool is_initialized =
false;
111 is_initialized =
true;
117 va_start(argptr, fmt);
118 (void)vsnprintf(DebugBuffer, DEBUG_BUF_SIZE, fmt, argptr);
124 const char *color_pfx =
"", *color_sfx =
"\33[0m";
128 case PCSC_LOG_CRITICAL:
129 color_pfx =
"\33[01;31m";
133 color_pfx =
"\33[35m";
137 color_pfx =
"\33[34m";
145 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
148 fprintf(stderr,
"%s\n", DebugBuffer);
static char LogLevel
default level is quiet to avoid polluting fd 2 (possibly NOT stderr)
static signed char LogDoColor
no color by default
This handles abstract system level calls.
const char * SYS_GetEnv(const char *name)
(More) secure version of getenv(3)