]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/output.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 static int log_f(int argc
, char **argv
);
29 static const cmdinfo_t log_cmd
=
30 { "log", NULL
, log_f
, 0, 2, 0, N_("[stop|start <filename>]"),
31 N_("start or stop logging to a file"), NULL
};
34 static FILE *log_file
;
35 static char *log_file_name
;
38 dbprintf(const char *fmt
, ...)
49 i
+= printf("%s: ", fsdevice
);
50 i
+= vprintf(fmt
, ap
);
55 vfprintf(log_file
, fmt
, ap
);
68 dbprintf(_("logging to %s\n"), log_file_name
);
70 dbprintf(_("no log file\n"));
71 } else if (argc
== 2 && strcmp(argv
[1], "stop") == 0) {
77 dbprintf(_("no log file\n"));
78 } else if (argc
== 3 && strcmp(argv
[1], "start") == 0) {
80 dbprintf(_("already logging to %s\n"), log_file_name
);
82 log_file
= fopen(argv
[2], "a");
84 dbprintf(_("can't open %s for writing\n"),
87 log_file_name
= xstrdup(argv
[1]);
90 dbprintf(_("bad log command, ignored\n"));
95 logprintf(const char *fmt
, ...)
101 (void)vfprintf(log_file
, fmt
, ap
);
109 add_command(&log_cmd
);