[Pcsclite-cvs-commit] CVS PCSC/src

CVS User rousseau ludovic.rousseau@free.fr
Wed, 25 May 2005 07:21:01 +0000


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv27426

Modified Files:
	debuglog.c 
Log Message:
check if we should use color logs in DebugLogSetLogType() and not only
the first time in log_msg()


--- /cvsroot/pcsclite/PCSC/src/debuglog.c	2005/04/13 06:34:05	1.42
+++ /cvsroot/pcsclite/PCSC/src/debuglog.c	2005/05/25 07:21:01	1.43
@@ -6,7 +6,7 @@
  * Copyright (C) 1999-2005
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: debuglog.c,v 1.42 2005/04/13 06:34:05 rousseau Exp $
+ * $Id: debuglog.c,v 1.43 2005/05/25 07:21:01 rousseau Exp $
  */
 
 /**
@@ -45,7 +45,7 @@
 /* default level is a bit verbose to be backward compatible */
 static char LogLevel = PCSC_LOG_INFO;
 
-static signed char LogDoColor = -1;	/* not initialised */
+static signed char LogDoColor = 0;	/* no color by default */
 
 void log_msg(const int priority, const char *fmt, ...)
 {
@@ -57,40 +57,6 @@
 		|| (DEBUGLOG_NO_DEBUG == LogMsgType))
 		return;
 
-	/* color not yet initialised? */
-	if (-1 == LogDoColor)
-	{
-		LogDoColor = 0;	/* no color by default */
-
-		/* no color under Windows */
-#ifndef WIN32
-
-		/* log to stderr and stderr is a tty? */
-		if (DEBUGLOG_STDERR_DEBUG == LogMsgType && isatty(fileno(stderr)))
-		{
-			const char *terms[] = { "linux", "xterm", "Eterm", "rxvt" };
-			char *term;
-
-			term = getenv("TERM");
-			if (term)
-			{
-				int i;
-
-				/* for each known color terminal */
-				for (i = 0; i < sizeof(terms) / sizeof(terms[0]); i++)
-				{
-					/* we found a supported term? */
-					if (0 == strcmp(terms[i], term))
-					{
-						LogDoColor = 1;
-						break;
-					}
-				}
-			}
-		}
-#endif
-	}
-
 	va_start(argptr, fmt);
 #ifndef WIN32
 	vsnprintf(DebugBuffer, DEBUG_BUF_SIZE, fmt, argptr);
@@ -194,6 +160,33 @@
 				dbgtype);
 			LogMsgType = DEBUGLOG_STDERR_DEBUG;
 	}
+
+	/* no color under Windows */
+#ifndef WIN32
+	/* log to stderr and stderr is a tty? */
+	if (DEBUGLOG_STDERR_DEBUG == LogMsgType && isatty(fileno(stderr)))
+	{
+		const char *terms[] = { "linux", "xterm", "Eterm", "rxvt" };
+		char *term;
+
+		term = getenv("TERM");
+		if (term)
+		{
+			int i;
+
+			/* for each known color terminal */
+			for (i = 0; i < sizeof(terms) / sizeof(terms[0]); i++)
+			{
+				/* we found a supported term? */
+				if (0 == strcmp(terms[i], term))
+				{
+					LogDoColor = 1;
+					break;
+				}
+			}
+		}
+	}
+#endif
 }
 
 void DebugLogSetLevel(const int level)