51#define DEBUG_BUF_SIZE 2048
55void log_msg(
const int priority,
const char *fmt, ...)
68static void log_init(
void)
72 e = getenv(
"PCSCLITE_DEBUG");
77 if (isatty(fileno(stderr)))
81 term = getenv(
"TERM");
84 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
88 for (i = 0; i < COUNT_OF(terms); i++)
91 if (0 == strcmp(terms[i], term))
101void log_msg(
const int priority,
const char *fmt, ...)
103 char DebugBuffer[DEBUG_BUF_SIZE];
105 static bool is_initialized =
false;
110 is_initialized =
true;
116 va_start(argptr, fmt);
117 (void)vsnprintf(DebugBuffer, DEBUG_BUF_SIZE, fmt, argptr);
123 const char *color_pfx =
"", *color_sfx =
"\33[0m";
127 case PCSC_LOG_CRITICAL:
128 color_pfx =
"\33[01;31m";
132 color_pfx =
"\33[35m";
136 color_pfx =
"\33[34m";
144 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
147 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