27 #define DEBUG_BUF_SIZE 2048
31 void log_msg(
const int priority,
const char *fmt, ...)
44 static void log_init(
void)
49 e = getenv(
"PCSCLITE_DEBUG");
51 e = getenv(
"MUSCLECARD_DEBUG");
57 if (isatty(fileno(stderr)))
59 const char *terms[] = {
"linux",
"xterm",
"xterm-color",
"Eterm",
"rxvt",
"rxvt-unicode" };
62 term = getenv(
"TERM");
68 for (i = 0; i <
sizeof(terms) /
sizeof(terms[0]); i++)
71 if (0 == strcmp(terms[i], term))
81 void log_msg(
const int priority,
const char *fmt, ...)
85 static int is_initialized = 0;
96 va_start(argptr, fmt);
103 const char *color_pfx =
"", *color_sfx =
"\33[0m";
107 case PCSC_LOG_CRITICAL:
108 color_pfx =
"\33[01;31m";
112 color_pfx =
"\33[35m";
116 color_pfx =
"\33[34m";
124 fprintf(stderr,
"%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
127 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