[Pcsclite-cvs-commit] r5710 - in /trunk/PCSC/src: PCSC/debuglog.h debuglog.c pcscdaemon.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu May 5 08:57:08 UTC 2011


Author: rousseau
Date: Thu May  5 08:57:07 2011
New Revision: 5710

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5710
Log:
Send logs to stdout instead of stderr

It is now possible to use tee(1) to redirect logs in a file without
first redirecting stderr to stdout

Modified:
    trunk/PCSC/src/PCSC/debuglog.h
    trunk/PCSC/src/debuglog.c
    trunk/PCSC/src/pcscdaemon.c

Modified: trunk/PCSC/src/PCSC/debuglog.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/PCSC/debuglog.h?rev=5710&op=diff
==============================================================================
--- trunk/PCSC/src/PCSC/debuglog.h (original)
+++ trunk/PCSC/src/PCSC/debuglog.h Thu May  5 08:57:07 2011
@@ -40,7 +40,7 @@
 enum {
 	DEBUGLOG_NO_DEBUG = 0,
 	DEBUGLOG_SYSLOG_DEBUG,
-	DEBUGLOG_STDERR_DEBUG
+	DEBUGLOG_STDOUT_DEBUG
 };
 
 #define DEBUG_CATEGORY_NOTHING  0

Modified: trunk/PCSC/src/debuglog.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/debuglog.c?rev=5710&op=diff
==============================================================================
--- trunk/PCSC/src/debuglog.c (original)
+++ trunk/PCSC/src/debuglog.c Thu May  5 08:57:07 2011
@@ -161,12 +161,12 @@
 			else
 				delta = 99999999;
 
-			fprintf(stderr, "%s%.8d%s %s%s%s\n", time_pfx, delta, time_sfx,
+			printf("%s%.8d%s %s%s%s\n", time_pfx, delta, time_sfx,
 				color_pfx, DebugBuffer, color_sfx);
 			last_time = new_time;
 		}
 		else
-			fprintf(stderr, "%s\n", DebugBuffer);
+			puts(DebugBuffer);
 	}
 } /* log_msg */
 
@@ -212,17 +212,17 @@
 	{
 		case DEBUGLOG_NO_DEBUG:
 		case DEBUGLOG_SYSLOG_DEBUG:
-		case DEBUGLOG_STDERR_DEBUG:
+		case DEBUGLOG_STDOUT_DEBUG:
 			LogMsgType = dbgtype;
 			break;
 		default:
-			Log2(PCSC_LOG_CRITICAL, "unknown log type (%d), using stderr",
+			Log2(PCSC_LOG_CRITICAL, "unknown log type (%d), using stdout",
 				dbgtype);
-			LogMsgType = DEBUGLOG_STDERR_DEBUG;
-	}
-
-	/* log to stderr and stderr is a tty? */
-	if (DEBUGLOG_STDERR_DEBUG == LogMsgType && isatty(fileno(stderr)))
+			LogMsgType = DEBUGLOG_STDOUT_DEBUG;
+	}
+
+	/* log to stdout and stdout is a tty? */
+	if (DEBUGLOG_STDOUT_DEBUG == LogMsgType && isatty(fileno(stdout)))
 	{
 		const char *terms[] = { "linux", "xterm", "xterm-color", "Eterm", "rxvt", "rxvt-unicode" };
 		char *term;
@@ -328,7 +328,7 @@
 	if (DEBUGLOG_SYSLOG_DEBUG == LogMsgType)
 		syslog(LOG_INFO, "%s", DebugBuffer);
 	else
-		fprintf(stderr, "%s\n", DebugBuffer);
+		puts(DebugBuffer);
 } /* debug_msg */
 
 void debug_xxd(const char *msg, const unsigned char *buffer, const int len);

Modified: trunk/PCSC/src/pcscdaemon.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscdaemon.c?rev=5710&op=diff
==============================================================================
--- trunk/PCSC/src/pcscdaemon.c (original)
+++ trunk/PCSC/src/pcscdaemon.c Thu May  5 08:57:07 2011
@@ -224,10 +224,10 @@
 
 			case 'f':
 				setToForeground = TRUE;
-				/* debug to stderr instead of default syslog */
-				DebugLogSetLogType(DEBUGLOG_STDERR_DEBUG);
+				/* debug to stdout instead of default syslog */
+				DebugLogSetLogType(DEBUGLOG_STDOUT_DEBUG);
 				Log1(PCSC_LOG_INFO,
-					"pcscd set to foreground with debug send to stderr");
+					"pcscd set to foreground with debug send to stdout");
 				break;
 
 			case 'd':
@@ -260,8 +260,8 @@
 				break;
 
 			case 'H':
-				/* debug to stderr instead of default syslog */
-				DebugLogSetLogType(DEBUGLOG_STDERR_DEBUG);
+				/* debug to stdout instead of default syslog */
+				DebugLogSetLogType(DEBUGLOG_STDOUT_DEBUG);
 				HotPlug = TRUE;
 				break;
 
@@ -732,7 +732,7 @@
 	printf("  -a, --apdu		log APDU commands and results\n");
 	printf("  -c, --config		path to reader.conf\n");
 	printf("  -f, --foreground	run in foreground (no daemon),\n");
-	printf("			send logs to stderr instead of syslog\n");
+	printf("			send logs to stdout instead of syslog\n");
 	printf("  -h, --help		display usage information\n");
 	printf("  -H, --hotplug		ask the daemon to rescan the available readers\n");
 	printf("  -v, --version		display the program version number\n");
@@ -747,7 +747,7 @@
 #else
 	printf("  -a    log APDU commands and results\n");
 	printf("  -c 	path to reader.conf\n");
-	printf("  -f	run in foreground (no daemon), send logs to stderr instead of syslog\n");
+	printf("  -f	run in foreground (no daemon), send logs to stdout instead of syslog\n");
 	printf("  -d 	display debug messages. Output may be:\n");
 	printf("  -h 	display usage information\n");
 	printf("  -H	ask the daemon to rescan the available readers\n");




More information about the Pcsclite-cvs-commit mailing list