50 #define DEBUG_BUF_SIZE 2048 54 void log_msg(
const int priority,
const char *fmt, ...)
67 static void log_init(
void)
72 e = getenv(
"PCSCLITE_DEBUG");
74 e = getenv(
"MUSCLECARD_DEBUG");
80 if (isatty(fileno(stderr)))
84 term = getenv(
"TERM");
87 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
91 for (i = 0; i < COUNT_OF(terms); i++)
94 if (0 == strcmp(terms[i], term))
104 void log_msg(
const int priority,
const char *fmt, ...)
108 static int is_initialized = 0;
119 va_start(argptr, fmt);
126 const char *color_pfx =
"", *color_sfx =
"\33[0m";
130 case PCSC_LOG_CRITICAL:
131 color_pfx =
"\33[01;31m";
135 color_pfx =
"\33[35m";
139 color_pfx =
"\33[34m";
147 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
150 fprintf(stderr,
"%s\n", DebugBuffer);
static char LogLevel
default level is quiet to avoid polluting fd 2 (possibly NOT stderr)
#define DEBUG_BUF_SIZE
Max string size dumping a maxmium of 2 lines of 80 characters.
static signed char LogDoColor
no color by default