Add a simplelog function that does not log date and time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/logging.c b/logging.c
index 52eb9ef..b242cb6 100644
--- a/logging.c
+++ b/logging.c
@@ -86,3 +86,23 @@ void _applog(int prio, const char *str, bool force)
my_log_curses(prio, datetime, str, force);
}
}
+
+void _simplelog(int prio, const char *str, bool force)
+{
+#ifdef HAVE_SYSLOG_H
+ if (use_syslog) {
+ syslog(prio, "%s", str);
+ }
+#else
+ if (0) {}
+#endif
+ else {
+ /* Only output to stderr if it's not going to the screen as well */
+ if (!isatty(fileno((FILE *)stderr))) {
+ fprintf(stderr, "%s\n", str); /* atomic write to stderr */
+ fflush(stderr);
+ }
+
+ my_log_curses(prio, "", str, force);
+ }
+}
diff --git a/logging.h b/logging.h
index 4d8a250..fd06e5c 100644
--- a/logging.h
+++ b/logging.h
@@ -29,6 +29,7 @@ extern int opt_log_level;
#define LOGBUFSIZ 256
extern void _applog(int prio, const char *str, bool force);
+extern void _simplelog(int prio, const char *str, bool force);
#define IN_FMT_FFL " in %s %s():%d"
@@ -42,6 +43,16 @@ extern void _applog(int prio, const char *str, bool force);
} \
} while (0)
+#define simplelog(prio, fmt, ...) do { \
+ if (opt_debug || prio != LOG_DEBUG) { \
+ if (use_syslog || opt_log_output || prio <= opt_log_level) { \
+ char tmp42[LOGBUFSIZ]; \
+ snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \
+ _simplelog(prio, tmp42, false); \
+ } \
+ } \
+} while (0)
+
#define applogsiz(prio, _SIZ, fmt, ...) do { \
if (opt_debug || prio != LOG_DEBUG) { \
if (use_syslog || opt_log_output || prio <= opt_log_level) { \