]> git.ozlabs.org Git - petitboot/blobdiff - ui/twin/main-generic.c
lib/log: Switch to pb_log_fn
[petitboot] / ui / twin / main-generic.c
index 99520d0adde32b040884ab5511c97e8b117eb828..a85cace0b8581c263881ff0285240b6a175282f8 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <assert.h>
 #include <errno.h>
 #include <getopt.h>
@@ -58,7 +57,7 @@ static int edit_preferences_cb(struct pbt_item *item)
 
        (void)client;
 
-       pb_log("%s: TODO\n", __func__);
+       pb_debug("%s: TODO\n", __func__);
 
        return 0;
 }
@@ -205,7 +204,7 @@ static int run(struct pbt_client *client)
                int result = waiter_poll(client->waitset);
 
                if (result < 0) {
-                       pb_log("%s: poll: %s\n", __func__, strerror(errno));
+                       pb_log_fn("poll: %s\n", strerror(errno));
                        break;
                }
 
@@ -268,6 +267,7 @@ int main(int argc, char *argv[])
        int result;
        int ui_result;
        struct pbt_client *client;
+       FILE *log;
 
        result = pbt_opts_parse(&opts, argc, argv);
 
@@ -286,17 +286,13 @@ int main(int argc, char *argv[])
                return EXIT_SUCCESS;
        }
 
+       log = stderr;
        if (strcmp(opts.log_file, "-")) {
                FILE *log = fopen(opts.log_file, "a");
-
-               assert(log);
-               pb_log_set_stream(log);
-       } else
-               pb_log_set_stream(stderr);
-
-#if defined(DEBUG)
-       pb_log_always_flush(1);
-#endif
+               if (!log)
+                       log = stderr;
+       }
+       pb_log_init(log);
 
        pb_log("--- petitboot-twin ---\n");
 
@@ -308,7 +304,7 @@ int main(int argc, char *argv[])
        result += sigaction(SIGWINCH, &sa, NULL);
 
        if (result) {
-               pb_log("%s sigaction failed.\n", __func__);
+               pb_log_fn("sigaction failed.\n");
                return EXIT_FAILURE;
        }