#include <getopt.h>
#include <stdlib.h>
#include <signal.h>
+#include <string.h>
#include <waiter/waiter.h>
#include <log/log.h>
struct opts opts;
struct udev *udev;
struct user_event *uev;
- FILE *log;
if (opts_parse(&opts, argc, argv)) {
print_usage();
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ 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);
va_list ap;
FILE *stream;
- stream = logf ? logf : stdout;
+ stream = logf ? logf : stderr;
va_start(ap, fmt);
vfprintf(stream, fmt, ap);
void pb_log_set_stream(FILE *stream)
{
- fflush(logf ? logf : stdout);
+ fflush(logf ? logf : stderr);
logf = stream;
}
FILE * pb_log_get_stream(void)
{
- return logf;
+ return logf ? logf : stderr;
}
void pb_log_always_flush(int state)
static struct opts opts;
int result;
int cui_result;
- FILE *log;
result = opts_parse(&opts, argc, argv);
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ 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);
int result;
int cui_result;
unsigned int mode;
- FILE *log;
result = opts_parse(&opts, argc, argv);
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ 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);
static struct pbt_opts opts;
int result;
int ui_result;
- FILE *log;
struct pbt_client *client;
result = pbt_opts_parse(&opts, argc, argv);
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ 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);
int result;
int ui_result = -1;
unsigned int mode;
- FILE *log;
result = pbt_opts_parse(&opts, argc, argv);
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ 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);