Skip to content

Commit

Permalink
Add option whether to include header when logging.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
net147 authored and sgtatham committed Sep 26, 2018
1 parent 686e78e commit 822d2fd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
9 changes: 9 additions & 0 deletions doc/config.but
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions putty.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 2 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions windows/winhelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 822d2fd

Please sign in to comment.