summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rwxr-xr-xlog.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/log.c b/log.c
index e409f4e..9fea0bd 100755
--- a/log.c
+++ b/log.c
@@ -1,7 +1,7 @@
/*
* log.c: VDR on Smart TV plugin
*
- * Copyright (C) 2012 Thorsten Lohmar
+ * Copyright (C) 2012 - 2014 T. Lohmar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,6 +23,7 @@
#include "log.h"
#include <time.h>
+#include <sys/time.h>
#include <cstring>
Log* Log::instance = NULL;
@@ -73,6 +74,18 @@ int Log::init(char* fileName) {
return 0;
}
+string Log::getTimeString() {
+ char timebuf[128];
+ char buf[128];
+
+ timeval now;
+ gettimeofday(&now, NULL);
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", gmtime(&now.tv_sec));
+
+ snprintf(buf, sizeof(buf), "%s.%ld", timebuf, (now.tv_usec / 1000));
+ return string(buf);
+};
+
int Log::shutdown() {
if (mLogFile)
mLogFile->close();