sim-card
/
qemu
Archived
10
0
Fork 0

Allow changing log filename.

Close logfile when logging is disabled.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3035 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
pbrook 2007-06-30 13:53:24 +00:00
parent 15f8220829
commit e735b91cd4
2 changed files with 19 additions and 1 deletions

13
exec.c
View File

@ -152,6 +152,7 @@ static int io_mem_watch;
char *logfilename = "/tmp/qemu.log"; char *logfilename = "/tmp/qemu.log";
FILE *logfile; FILE *logfile;
int loglevel; int loglevel;
static int log_append = 0;
/* statistics */ /* statistics */
static int tlb_flush_count; static int tlb_flush_count;
@ -1160,7 +1161,7 @@ void cpu_set_log(int log_flags)
{ {
loglevel = log_flags; loglevel = log_flags;
if (loglevel && !logfile) { if (loglevel && !logfile) {
logfile = fopen(logfilename, "w"); logfile = fopen(logfilename, log_append ? "wa" : "w");
if (!logfile) { if (!logfile) {
perror(logfilename); perror(logfilename);
_exit(1); _exit(1);
@ -1174,12 +1175,22 @@ void cpu_set_log(int log_flags)
#else #else
setvbuf(logfile, NULL, _IOLBF, 0); setvbuf(logfile, NULL, _IOLBF, 0);
#endif #endif
log_append = 1;
}
if (!loglevel && logfile) {
fclose(logfile);
logfile = NULL;
} }
} }
void cpu_set_log_filename(const char *filename) void cpu_set_log_filename(const char *filename)
{ {
logfilename = strdup(filename); logfilename = strdup(filename);
if (logfile) {
fclose(logfile);
logfile = NULL;
}
cpu_set_log(loglevel);
} }
/* mask must never be zero, except for A20 change call */ /* mask must never be zero, except for A20 change call */

View File

@ -406,6 +406,11 @@ static void do_screen_dump(const char *filename)
vga_hw_screen_dump(filename); vga_hw_screen_dump(filename);
} }
static void do_logfile(const char *filename)
{
cpu_set_log_filename(filename);
}
static void do_log(const char *items) static void do_log(const char *items)
{ {
int mask; int mask;
@ -1213,6 +1218,8 @@ static term_cmd_t term_cmds[] = {
"device filename", "change a removable medium" }, "device filename", "change a removable medium" },
{ "screendump", "F", do_screen_dump, { "screendump", "F", do_screen_dump,
"filename", "save screen into PPM image 'filename'" }, "filename", "save screen into PPM image 'filename'" },
{ "logfile", "s", do_logfile,
"filename", "output logs to 'filename'" },
{ "log", "s", do_log, { "log", "s", do_log,
"item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" },
{ "savevm", "s?", do_savevm, { "savevm", "s?", do_savevm,