chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial resample.c implementation
[disorder]
/
lib
/
log.c
diff --git
a/lib/log.c
b/lib/log.c
index 3f57073a1ef6bb2834c0f7b830c7f46df817a894..00ec7cd3a2a4f8039321fba3be74f3ae64bc7532 100644
(file)
--- a/
lib/log.c
+++ b/
lib/log.c
@@
-38,6
+38,7
@@
#include <errno.h>
#include <syslog.h>
#include <sys/time.h>
#include <errno.h>
#include <syslog.h>
#include <sys/time.h>
+#include <time.h>
#include "log.h"
#include "disorder.h"
#include "log.h"
#include "disorder.h"
@@
-66,6
+67,9
@@
const char *progname;
/** @brief Filename for debug messages */
const char *debug_filename;
/** @brief Filename for debug messages */
const char *debug_filename;
+/** @brief Set to include timestamps in log messages */
+int logdate;
+
/** @brief Line number for debug messages */
int debug_lineno;
/** @brief Line number for debug messages */
int debug_lineno;
@@
-119,7
+123,15
@@
static void logfp(int pri, const char *msg, void *user) {
* sanely */
const char *p;
* sanely */
const char *p;
- if(progname)
+ if(logdate) {
+ char timebuf[64];
+ struct tm *tm;
+ gettimeofday(&tv, 0);
+ tm = localtime(&tv.tv_sec);
+ strftime(timebuf, sizeof timebuf, "%Y-%m-%d %H:%M:%S %Z", tm);
+ fprintf(fp, "%s: ", timebuf);
+ }
+ if(progname)
fprintf(fp, "%s: ", progname);
if(pri <= LOG_ERR)
fputs("ERROR: ", fp);
fprintf(fp, "%s: ", progname);
if(pri <= LOG_ERR)
fputs("ERROR: ", fp);