From 822d2fd4c3239b818bcb697f0905a217d6c783a9 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Wed, 26 Sep 2018 20:48:11 +1000 Subject: [PATCH] Add option whether to include header when logging. It is useful to be able to exclude the header so that the log file can be used for realtime input to other programs such as Kst for plotting live data from sensors. --- config.c | 3 +++ doc/config.but | 9 +++++++++ logging.c | 2 +- putty.h | 1 + settings.c | 2 ++ windows/winhelp.h | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index bdffd6bb..26d57acc 100644 --- a/config.c +++ b/config.c @@ -1628,6 +1628,9 @@ void setup_config_box(struct controlbox *b, int midsession, ctrl_checkbox(s, "Flush log file frequently", 'u', HELPCTX(logging_flush), conf_checkbox_handler, I(CONF_logflush)); + ctrl_checkbox(s, "Include header", 'h', + HELPCTX(logging_header), + conf_checkbox_handler, I(CONF_logheader)); if ((midsession && protocol == PROT_SSH) || (!midsession && backend_vt_from_proto(PROT_SSH))) { diff --git a/doc/config.but b/doc/config.but index c76e1847..96323ce6 100644 --- a/doc/config.but +++ b/doc/config.but @@ -246,6 +246,15 @@ warned that the log file may not always be up to date as a result (although it will of course be flushed when it is closed, for instance at the end of a session). +\S{config-logheader} \I{log file, header}\q{Include header} + +\cfg{winhelp-topic}{logging.header} + +This option allows you to choose whether to include a header line +with the date and time when the log file is opened. It may be useful to +disable this if the log file is being used as realtime input to other +programs that don't expect the header line. + \S{config-logssh} Options specific to \i{SSH packet log}ging These options only apply if SSH packet data is being logged. diff --git a/logging.c b/logging.c index 0393b7bf..da502c86 100644 --- a/logging.c +++ b/logging.c @@ -103,7 +103,7 @@ static void logfopen_callback(void *vctx, int mode) } } - if (ctx->state == L_OPEN) { + if (ctx->state == L_OPEN && conf_get_int(ctx->conf, CONF_logheader)) { /* Write header line into log file. */ tm = ltime(); strftime(buf, 24, "%Y.%m.%d %H:%M:%S", &tm); diff --git a/putty.h b/putty.h index 3963e48e..1a0d1ca2 100644 --- a/putty.h +++ b/putty.h @@ -931,6 +931,7 @@ void cleanup_exit(int); X(INT, NONE, logtype) \ X(INT, NONE, logxfovr) \ X(INT, NONE, logflush) \ + X(INT, NONE, logheader) \ X(INT, NONE, logomitpass) \ X(INT, NONE, logomitdata) \ X(INT, NONE, hide_mouseptr) \ diff --git a/settings.c b/settings.c index ab735488..5b613b66 100644 --- a/settings.c +++ b/settings.c @@ -524,6 +524,7 @@ void save_open_settings(settings_w *sesskey, Conf *conf) write_setting_i(sesskey, "LogType", conf_get_int(conf, CONF_logtype)); write_setting_i(sesskey, "LogFileClash", conf_get_int(conf, CONF_logxfovr)); write_setting_i(sesskey, "LogFlush", conf_get_int(conf, CONF_logflush)); + write_setting_i(sesskey, "LogHeader", conf_get_int(conf, CONF_logheader)); write_setting_i(sesskey, "SSHLogOmitPasswords", conf_get_int(conf, CONF_logomitpass)); write_setting_i(sesskey, "SSHLogOmitData", conf_get_int(conf, CONF_logomitdata)); p = "raw"; @@ -785,6 +786,7 @@ void load_open_settings(settings_r *sesskey, Conf *conf) gppi(sesskey, "LogType", 0, conf, CONF_logtype); gppi(sesskey, "LogFileClash", LGXF_ASK, conf, CONF_logxfovr); gppi(sesskey, "LogFlush", 1, conf, CONF_logflush); + gppi(sesskey, "LogHeader", 1, conf, CONF_logheader); gppi(sesskey, "SSHLogOmitPasswords", 1, conf, CONF_logomitpass); gppi(sesskey, "SSHLogOmitData", 0, conf, CONF_logomitdata); diff --git a/windows/winhelp.h b/windows/winhelp.h index c9be5f44..2ecb537a 100644 --- a/windows/winhelp.h +++ b/windows/winhelp.h @@ -23,6 +23,7 @@ #define WINHELP_CTX_logging_filename "logging.filename:config-logfilename" #define WINHELP_CTX_logging_exists "logging.exists:config-logfileexists" #define WINHELP_CTX_logging_flush "logging.flush:config-logflush" +#define WINHELP_CTX_logging_header "logging.header:config-logheader" #define WINHELP_CTX_logging_ssh_omit_password "logging.ssh.omitpassword:config-logssh" #define WINHELP_CTX_logging_ssh_omit_data "logging.ssh.omitdata:config-logssh" #define WINHELP_CTX_keyboard_backspace "keyboard.backspace:config-backspace"