From 0d3ab7306e1060f3c0031d303a79dfcf256cb55f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 27 Feb 2001 17:02:51 +0000 Subject: [PATCH] Timestamp every line of the Event Log. The primary reason for this (generating detail in bug reports when SSH2 repeat key exchange failed) is no longer an issue, but it might be useful for other things. It's a _log_ dammit, and logs should be timestamped. [originally from svn r956] --- win_res.rc | 4 ++-- windlg.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/win_res.rc b/win_res.rc index 6b8a3893..156019d4 100644 --- a/win_res.rc +++ b/win_res.rc @@ -52,14 +52,14 @@ BEGIN END /* Accelerators used: co */ -IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 260, 119 +IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 300, 119 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "PuTTY Event Log" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "&Close", IDOK, 135, 102, 44, 14 PUSHBUTTON "C&opy", IDN_COPY, 81, 102, 44, 14 - LISTBOX IDN_LIST, 3, 3, 254, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | LBS_EXTENDEDSEL + LISTBOX IDN_LIST, 3, 3, 294, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | LBS_EXTENDEDSEL END /* No accelerators used */ diff --git a/windlg.c b/windlg.c index f164f3e0..7f994680 100644 --- a/windlg.c +++ b/windlg.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "ssh.h" #include "putty.h" @@ -2038,12 +2039,20 @@ int do_reconfig (HWND hwnd) { } void logevent (char *string) { + char timebuf[40]; + time_t t; + if (nevents >= negsize) { negsize += 64; events = srealloc (events, negsize * sizeof(*events)); } - events[nevents] = smalloc(1+strlen(string)); - strcpy (events[nevents], string); + + time(&t); + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S ", localtime(&t)); + + events[nevents] = smalloc(strlen(timebuf)+strlen(string)+1); + strcpy(events[nevents], timebuf); + strcat(events[nevents], string); nevents++; if (logbox) { int count; -- 2.45.2