#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
-#include "githead.h"
+#include "shl_githead.h"
#include "shl_log.h"
#include "shl_misc.h"
if (file) {
f = fopen(file, "a");
if (!f) {
- log_err("cannot change log-file to %s (%d): %s",
- file, errno, strerror(errno));
+ log_err("cannot change log-file to %s (%d): %m",
+ file, errno);
return -EFAULT;
}
} else {
const char *prefix = NULL;
FILE *out;
long long sec, usec;
+ bool nl;
+ size_t len;
if (log__omit(file, line, func, config, subs, sev))
return;
fprintf(out, "[%.4lld.%.6lld] ", sec, usec);
}
+ len = strlen(format);
+ nl = format[len - 1] == '\n';
+
+ if (!func)
+ func = "<unknown>";
+ if (!file)
+ file = "<unknown>";
+ if (line < 0)
+ line = 0;
+
vfprintf(out, format, args);
- if (sev == LOG_DEBUG) {
- if (!func)
- func = "<unknown>";
- if (!file)
- file = "<unknown>";
- if (line < 0)
- line = 0;
+ if (!nl)
fprintf(out, " (%s() in %s:%d)\n", func, file, line);
- } else {
- fprintf(out, "\n");
- }
}
static void log__format(const char *file,
appname = "<unknown>";
log_format(LOG_DEFAULT_CONF, NULL, LOG_NOTICE,
"%s Revision %s %s %s", appname,
- BUILD_GIT_HEAD, __DATE__, __TIME__);
+ shl_git_head, __DATE__, __TIME__);
}