]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Move the stderr output of event log messages in verbose mode to the
authorSimon Tatham <anakin@pobox.com>
Thu, 19 Dec 2002 14:24:28 +0000 (14:24 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 19 Dec 2002 14:24:28 +0000 (14:24 +0000)
general logging module rather than localising it in ssh.c. This
means it should work in other protocols as well (notably Telnet,
where it might actually be useful for debugging negotiations).

git-svn-id: http://svn.tartarus.org/sgt/putty@2360 cda61777-01e9-0310-a592-d414129be87e

logging.c
ssh.c

index 06f0678b34a708e5d4dc98cde9ea4defd45a5f42..9e8b9f83eb82cc454ae48c65545f16ea8d9c42b5 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -34,11 +34,21 @@ void logtraffic(void *handle, unsigned char c, int logmode)
 }
 
 /*
- * Log an Event Log entry (used in SSH packet logging mode).
+ * Log an Event Log entry. Used in SSH packet logging mode; this is
+ * also as convenient a place as any to put the output of Event Log
+ * entries to stderr when a command-line tool is in verbose mode.
+ * (In particular, this is a better place to put it than in the
+ * front ends, because it only has to be done once for all
+ * platforms. Platforms which don't have a meaningful stderr can
+ * just avoid defining FLAG_STDERR.
  */
 void log_eventlog(void *handle, char *event)
 {
     struct LogContext *ctx = (struct LogContext *)handle;
+    if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) {
+       fprintf(stderr, "%s\n", event);
+       fflush(stderr);
+    }
     if (cfg.logtype != LGTYP_PACKETS)
        return;
     if (!ctx->lgfp)
diff --git a/ssh.c b/ssh.c
index 0ac24d26ce9d9142c7763b276d85bc4b372d7e59..ccd3ea08c3d541c3aad493c8f8a0e506a9d2197b 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -638,13 +638,7 @@ struct ssh_tag {
     int (*s_rdpkt) (Ssh ssh, unsigned char **data, int *datalen);
 };
 
-#define logevent(s) do { \
-    logevent(ssh->frontend, s); \
-    if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) { \
-       fprintf(stderr, "%s\n", s); \
-       fflush(stderr); \
-    } \
-} while (0)
+#define logevent(s) logevent(ssh->frontend, s)
 
 /* logevent, only printf-formatted. */
 void logeventf(Ssh ssh, char *fmt, ...)