30 #define DEBUG_BUF_SIZE 2048
34 void log_msg(
const int priority,
const char *fmt, ...)
47 static void log_init(
void)
52 e = getenv(
"PCSCLITE_DEBUG");
54 e = getenv(
"MUSCLECARD_DEBUG");
60 if (isatty(fileno(stderr)))
64 term = getenv(
"TERM");
67 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
71 for (i = 0; i < COUNT_OF(terms); i++)
74 if (0 == strcmp(terms[i], term))
84 void log_msg(
const int priority,
const char *fmt, ...)
88 static int is_initialized = 0;
99 va_start(argptr, fmt);
106 const char *color_pfx =
"", *color_sfx =
"\33[0m";
110 case PCSC_LOG_CRITICAL:
111 color_pfx =
"\33[01;31m";
115 color_pfx =
"\33[35m";
119 color_pfx =
"\33[34m";
127 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
130 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.
prototypes of strlcpy()/strlcat() imported from OpenBSD
static signed char LogDoColor
no color by default