summaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-30 13:53:24 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-30 13:53:24 +0000
commite735b91cd44e5dafb83ed4158a4c6721c0b289aa (patch)
tree5183c87b9e68977258a9de7df45e3214da36f995 /exec.c
parent15f8220829f9a3e8911c81d1cdf662769987e37f (diff)
downloadqemu-e735b91cd44e5dafb83ed4158a4c6721c0b289aa.zip
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
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/exec.c b/exec.c
index 5fbeb8dce4..5ed63de684 100644
--- a/exec.c
+++ b/exec.c
@@ -152,6 +152,7 @@ static int io_mem_watch;
char *logfilename = "/tmp/qemu.log";
FILE *logfile;
int loglevel;
+static int log_append = 0;
/* statistics */
static int tlb_flush_count;
@@ -1160,7 +1161,7 @@ void cpu_set_log(int log_flags)
{
loglevel = log_flags;
if (loglevel && !logfile) {
- logfile = fopen(logfilename, "w");
+ logfile = fopen(logfilename, log_append ? "wa" : "w");
if (!logfile) {
perror(logfilename);
_exit(1);
@@ -1174,12 +1175,22 @@ void cpu_set_log(int log_flags)
#else
setvbuf(logfile, NULL, _IOLBF, 0);
#endif
+ log_append = 1;
+ }
+ if (!loglevel && logfile) {
+ fclose(logfile);
+ logfile = NULL;
}
}
void cpu_set_log_filename(const char *filename)
{
logfilename = strdup(filename);
+ if (logfile) {
+ fclose(logfile);
+ logfile = NULL;
+ }
+ cpu_set_log(loglevel);
}
/* mask must never be zero, except for A20 change call */