]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/output.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
15 static int log_f(int argc
, char **argv
);
17 static const cmdinfo_t log_cmd
=
18 { "log", NULL
, log_f
, 0, 2, 0, N_("[stop|start <filename>]"),
19 N_("start or stop logging to a file"), NULL
};
22 static FILE *log_file
;
23 static char *log_file_name
;
26 dbprintf(const char *fmt
, ...)
37 i
+= printf("%s: ", fsdevice
);
38 i
+= vprintf(fmt
, ap
);
43 vfprintf(log_file
, fmt
, ap
);
56 dbprintf(_("logging to %s\n"), log_file_name
);
58 dbprintf(_("no log file\n"));
59 } else if (argc
== 2 && strcmp(argv
[1], "stop") == 0) {
65 dbprintf(_("no log file\n"));
66 } else if (argc
== 3 && strcmp(argv
[1], "start") == 0) {
68 dbprintf(_("already logging to %s\n"), log_file_name
);
70 log_file
= fopen(argv
[2], "a");
72 dbprintf(_("can't open %s for writing\n"),
75 log_file_name
= xstrdup(argv
[1]);
78 dbprintf(_("bad log command, ignored\n"));
83 logprintf(const char *fmt
, ...)
89 (void)vfprintf(log_file
, fmt
, ap
);
97 add_command(&log_cmd
);