debug: Add file backend
authorChristof Schmitt <cs@samba.org>
Fri, 9 Jan 2015 21:00:02 +0000 (14:00 -0700)
committerChristof Schmitt <cs@samba.org>
Mon, 23 Mar 2015 20:22:11 +0000 (21:22 +0100)
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
lib/util/debug.c

index 9eba5b823bd5ac4f68ae3abad6df60631082e99f..e085aea9e01fc6f3c0b8b0932d8747f7736f32c6 100644 (file)
@@ -131,6 +131,13 @@ static int debug_level_to_priority(int level)
  * all active backends.
  */
 
+static void debug_file_log(int msg_level,
+                          const char *msg, const char *msg_no_nl)
+{
+       check_log_size();
+       write(state.fd, msg, strlen(msg));
+}
+
 static struct debug_backend {
        const char *name;
        int log_level;
@@ -138,6 +145,10 @@ static struct debug_backend {
        void (*reload)(bool enabled, bool prev_enabled, const char *prog_name);
        void (*log)(int msg_level, const char *msg, const char *msg_no_nl);
 } debug_backends[] = {
+       {
+               .name = "file",
+               .log = debug_file_log,
+       },
 };
 
 static struct debug_backend *debug_find_backend(const char *name)