script: cleanup info logging
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
7c4a374f63
commit
fd42a45bea
|
@ -145,7 +145,6 @@ struct script_control {
|
||||||
|
|
||||||
struct script_log *siglog; /* log for signal entries */
|
struct script_log *siglog; /* log for signal entries */
|
||||||
struct script_log *infolog; /* log for info entries */
|
struct script_log *infolog; /* log for info entries */
|
||||||
struct script_log *tmlog; /* timing log */
|
|
||||||
|
|
||||||
const char *ttyname;
|
const char *ttyname;
|
||||||
const char *ttytype;
|
const char *ttytype;
|
||||||
|
@ -296,8 +295,6 @@ static struct script_log *log_associate(struct script_control *ctl,
|
||||||
ctl->siglog = log;
|
ctl->siglog = log;
|
||||||
if (!ctl->infolog)
|
if (!ctl->infolog)
|
||||||
ctl->infolog = log;
|
ctl->infolog = log;
|
||||||
if (!ctl->tmlog)
|
|
||||||
ctl->tmlog = log;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return log;
|
return log;
|
||||||
|
@ -392,6 +389,19 @@ static void log_start(struct script_control *ctl,
|
||||||
log->initialized = 1;
|
log->initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void start_logging(struct script_control *ctl)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* start all output logs */
|
||||||
|
for (i = 0; i < ctl->out.nlogs; i++)
|
||||||
|
log_start(ctl, ctl->out.logs[i]);
|
||||||
|
|
||||||
|
/* start all input logs */
|
||||||
|
for (i = 0; i < ctl->in.nlogs; i++)
|
||||||
|
log_start(ctl, ctl->in.logs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
static size_t log_write(struct script_control *ctl,
|
static size_t log_write(struct script_control *ctl,
|
||||||
struct script_stream *stream,
|
struct script_stream *stream,
|
||||||
struct script_log *log,
|
struct script_log *log,
|
||||||
|
@ -493,7 +503,7 @@ static uint64_t log_signal(struct script_control *ctl, int signum, char *msgfmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*msg)
|
if (*msg)
|
||||||
sz = fprintf(log->fp, "S %ld.%06ld SIG%s [%s]\n",
|
sz = fprintf(log->fp, "S %ld.%06ld SIG%s %s\n",
|
||||||
(long)delta.tv_sec, (long)delta.tv_usec,
|
(long)delta.tv_sec, (long)delta.tv_usec,
|
||||||
signum_to_signame(signum), msg);
|
signum_to_signame(signum), msg);
|
||||||
else
|
else
|
||||||
|
@ -531,7 +541,7 @@ static uint64_t log_info(struct script_control *ctl, const char *name, const cha
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*msg)
|
if (*msg)
|
||||||
sz = fprintf(log->fp, "H 0 %s [%s]\n", name, msg);
|
sz = fprintf(log->fp, "H 0 %s %s\n", name, msg);
|
||||||
else
|
else
|
||||||
sz = fprintf(log->fp, "H 0 %s\n", name);
|
sz = fprintf(log->fp, "H 0 %s\n", name);
|
||||||
|
|
||||||
|
@ -805,7 +815,6 @@ static void handle_signal(struct script_control *ctl, int fd)
|
||||||
static void do_io(struct script_control *ctl)
|
static void do_io(struct script_control *ctl)
|
||||||
{
|
{
|
||||||
int ret, eof = 0;
|
int ret, eof = 0;
|
||||||
size_t i;
|
|
||||||
enum {
|
enum {
|
||||||
POLLFD_SIGNAL = 0,
|
POLLFD_SIGNAL = 0,
|
||||||
POLLFD_MASTER,
|
POLLFD_MASTER,
|
||||||
|
@ -818,26 +827,6 @@ static void do_io(struct script_control *ctl)
|
||||||
[POLLFD_STDIN] = { .fd = STDIN_FILENO, .events = POLLIN | POLLERR | POLLHUP }
|
[POLLFD_STDIN] = { .fd = STDIN_FILENO, .events = POLLIN | POLLERR | POLLHUP }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* start all output logs */
|
|
||||||
for (i = 0; i < ctl->out.nlogs; i++)
|
|
||||||
log_start(ctl, ctl->out.logs[i]);
|
|
||||||
|
|
||||||
/* start all input logs */
|
|
||||||
for (i = 0; i < ctl->in.nlogs; i++)
|
|
||||||
log_start(ctl, ctl->in.logs[i]);
|
|
||||||
|
|
||||||
/* log basic information */
|
|
||||||
if (ctl->isterm) {
|
|
||||||
init_terminal_info(ctl);
|
|
||||||
log_info(ctl, "TERM", ctl->ttytype);
|
|
||||||
log_info(ctl, "TTY", ctl->ttyname);
|
|
||||||
log_info(ctl, "COLUMNS", "%d", ctl->ttycols);
|
|
||||||
log_info(ctl, "LINES", "%d", ctl->ttylines);
|
|
||||||
}
|
|
||||||
log_info(ctl, "SHELL", ctl->shell);
|
|
||||||
if (ctl->tmlog)
|
|
||||||
log_info(ctl, "TIMING_LOG", ctl->tmlog->filename);
|
|
||||||
|
|
||||||
while (!ctl->die) {
|
while (!ctl->die) {
|
||||||
size_t i;
|
size_t i;
|
||||||
int errsv;
|
int errsv;
|
||||||
|
@ -1202,7 +1191,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
getmaster(&ctl);
|
getmaster(&ctl);
|
||||||
|
|
||||||
|
|
||||||
if (!ctl.quiet) {
|
if (!ctl.quiet) {
|
||||||
printf(_("Script started"));
|
printf(_("Script started"));
|
||||||
if (outfile)
|
if (outfile)
|
||||||
|
@ -1247,6 +1235,23 @@ int main(int argc, char **argv)
|
||||||
do_shell(&ctl);
|
do_shell(&ctl);
|
||||||
break;
|
break;
|
||||||
default: /* parent */
|
default: /* parent */
|
||||||
|
start_logging(&ctl);
|
||||||
|
|
||||||
|
if (timingfile && format == SCRIPT_FMT_TIMING_MULTI) {
|
||||||
|
if (ctl.isterm) {
|
||||||
|
init_terminal_info(&ctl);
|
||||||
|
log_info(&ctl, "TERM", ctl.ttytype);
|
||||||
|
log_info(&ctl, "TTY", ctl.ttyname);
|
||||||
|
log_info(&ctl, "COLUMNS", "%d", ctl.ttycols);
|
||||||
|
log_info(&ctl, "LINES", "%d", ctl.ttylines);
|
||||||
|
}
|
||||||
|
log_info(&ctl, "SHELL", ctl.shell);
|
||||||
|
log_info(&ctl, "TIMING_LOG", timingfile);
|
||||||
|
if (outfile)
|
||||||
|
log_info(&ctl, "OUTPUT_LOG", outfile);
|
||||||
|
if (infile)
|
||||||
|
log_info(&ctl, "INPUT_LOG", infile);
|
||||||
|
}
|
||||||
do_io(&ctl);
|
do_io(&ctl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue