summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-07-31 01:42:10 +0200
committerSebastian Reichel <sre@ring0.de>2012-07-31 01:42:10 +0200
commit44a70a656c994d1a6edc021355dc506e8a98e7a4 (patch)
tree5963f3b81ceb63223e6377a895a396768aa9b1cf
parent63f3f8502ae035886ee190cf3f57b68d43b35009 (diff)
downloadmicrocopterd-44a70a656c994d1a6edc021355dc506e8a98e7a4.tar.bz2
print log entries with timestamp
-rw-r--r--log.vala7
1 files changed, 6 insertions, 1 deletions
diff --git a/log.vala b/log.vala
index a4f9842..71b5875 100644
--- a/log.vala
+++ b/log.vala
@@ -1,16 +1,21 @@
namespace Log {
private unowned FileStream file;
private FileStream fileowner;
+ private long start_timestamp;
public void init() {
+ TimeVal time = {0};
+ time.get_current_time();
+
set_file(cfg.get_string("config", "logfile"));
GLib.Log.set_default_handler(log_handler);
+ start_timestamp = time.tv_sec;
}
private void log_handler(string? domain, LogLevelFlags flags, string message) {
TimeVal time = {0};
time.get_current_time();
- string s = "%.10ld | %15s | %s\n".printf(time.tv_usec, domain, message);
+ string s = "%.10ld | %15s | %s\n".printf(time.tv_sec - start_timestamp, domain, message);
if(file != null) {
file.printf(s);