50 #define DEBUG_BUF_SIZE 2048
54 void log_msg(
const int priority,
const char *fmt, ...)
67 static void log_init(
void)
71 e = getenv(
"PCSCLITE_DEBUG");
76 if (isatty(fileno(stderr)))
80 term = getenv(
"TERM");
83 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
87 for (i = 0; i < COUNT_OF(terms); i++)
90 if (0 == strcmp(terms[i], term))
100 void log_msg(
const int priority,
const char *fmt, ...)
104 static int is_initialized = 0;
115 va_start(argptr, fmt);
122 const char *color_pfx =
"", *color_sfx =
"\33[0m";
126 case PCSC_LOG_CRITICAL:
127 color_pfx =
"\33[01;31m";
131 color_pfx =
"\33[35m";
135 color_pfx =
"\33[34m";
143 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
146 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
#define DEBUG_BUF_SIZE
Max string size dumping a maxmium of 2 lines of 80 characters.