summaryrefslogtreecommitdiffstats
path: root/discover/pb-discover.c
diff options
context:
space:
mode:
Diffstat (limited to 'discover/pb-discover.c')
-rw-r--r--discover/pb-discover.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/discover/pb-discover.c b/discover/pb-discover.c
index 6d62e14..c16d690 100644
--- a/discover/pb-discover.c
+++ b/discover/pb-discover.c
@@ -123,6 +123,7 @@ int main(int argc, char *argv[])
struct opts opts;
struct pb_udev *udev;
struct user_event *uev;
+ FILE *log;
if (opts_parse(&opts, argc, argv)) {
print_usage();
@@ -139,17 +140,17 @@ 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);
+ log = fopen(opts.log_file, "a");
+ if (!log) {
+ fprintf(stderr, "can't open log file %s, logging to "
+ "stderr\n", opts.log_file);
+ log = stderr;
+ }
+ }
+ pb_log_init(log);
-#if defined(DEBUG)
- pb_log_always_flush(1);
-#endif
pb_log("--- pb-discover ---\n");
/* we look for closed sockets when we write, so ignore SIGPIPE */
OpenPOWER on IntegriCloud