summaryrefslogtreecommitdiff
path: root/navit/log.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-09-23 20:59:58 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-09-23 20:59:58 +0000
commit24ac49e89cdb852bce558de707a4aabbdae7d350 (patch)
treee195da7cfa35c3d8bf05810cb4dfe21385d49574 /navit/log.c
parent7a30a5c6928a5b3fbe4cc2292897c420968f89ac (diff)
downloadnavit-24ac49e89cdb852bce558de707a4aabbdae7d350.tar.gz
Fix:core:Fixed various logging bugs
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1406 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/log.c')
-rw-r--r--navit/log.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/navit/log.c b/navit/log.c
index f571b79bf..137bb9547 100644
--- a/navit/log.c
+++ b/navit/log.c
@@ -85,6 +85,12 @@ expand_filenames(struct log *this_)
}
static void
+log_set_last_flush(struct log *this_)
+{
+ gettimeofday(&this_->last_flush, NULL);
+}
+
+static void
log_open(struct log *this_)
{
char *mode;
@@ -102,7 +108,7 @@ log_open(struct log *this_)
if (!this_->overwrite)
fseek(this_->f, 0, SEEK_END);
this_->empty = !ftell(this_->f);
- gettimeofday(&this_->last_flush, NULL);
+ log_set_last_flush(this_);
}
static void
@@ -147,7 +153,7 @@ log_flush(struct log *this_)
g_free(this_->data.data);
this_->data.data=NULL;
this_->data.max_len=this_->data.len=0;
- gettimeofday(&this_->last_flush, NULL);
+ log_set_last_flush(this_);
}
static int
@@ -185,7 +191,7 @@ log_timer(gpointer data)
gettimeofday(&tv, NULL);
delta=(tv.tv_sec-this_->last_flush.tv_sec)*1000+(tv.tv_usec-this_->last_flush.tv_usec)/1000;
dbg(1,"delta=%d flush_time=%d\n", delta, this_->flush_time);
- if (this_->flush_time && delta > this_->flush_time*1000)
+ if (this_->flush_time && delta >= this_->flush_time*1000)
log_flush(this_);
return TRUE;
}
@@ -239,7 +245,9 @@ log_new(struct attr **attrs)
ret->timer=g_timeout_add(ret->flush_time*1000, log_timer, ret);
}
expand_filenames(ret);
- if (! ret->lazy)
+ if (ret->lazy)
+ log_set_last_flush(ret);
+ else
log_open(ret);
ret->attrs=attr_list_dup(attrs);
return ret;