Importing all of DRL, including ulogd and all of its files.
[distributedratelimiting.git] / drl / logging.c
diff --git a/drl/logging.c b/drl/logging.c
new file mode 100644 (file)
index 0000000..ca3d7c1
--- /dev/null
@@ -0,0 +1,25 @@
+/* See the DRL-LICENSE file for this file's software license. */
+#include <stdio.h>
+
+#include "logging.h"
+
+FILE *logfile;
+uint8_t system_loglevel;
+
+inline void printlog(const uint8_t level, const char *format, ...) {
+    va_list args;
+
+    if (system_loglevel <= level) {
+        va_start(args, format);
+        vfprintf(logfile, format, args);
+        va_end(args);
+    }
+}
+
+void flushlog() {
+    fflush(logfile);
+}
+
+int loglevel() {
+    return system_loglevel;
+}