Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ struct callbacks {
void (*log_info)(void *logger, const char *file, int line,
const char *function, const char *format, ...)
__attribute__((format(printf, 5, 6)));

/* Notify the logger to log to stderr. */
void (*logtostderr)(void *logger);
};

struct options {
Expand Down
11 changes: 2 additions & 9 deletions logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/* TODO remove global variables */
static int stdout_lines;
static FILE *log_file;
static bool g_logtostderr;

static void print(void *logger, const char *key, const char *value_fmt, ...)
{
Expand Down Expand Up @@ -135,7 +134,7 @@ static void logging(const char *file, int line, const char *func,
if (thread_id == -1)
thread_id = getpid();
path = strdup(file);
fprintf(g_logtostderr ? stderr : log_file,
fprintf(log_file,
"%c%02d%02d %02d:%02d:%02d.%06ld %3d %6d %s:%d] %s: %s\n",
level_char, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
tm.tm_sec, ts.tv_nsec / 1000, stdout_lines, thread_id,
Expand All @@ -147,7 +146,7 @@ static void logging(const char *file, int line, const char *func,
if (size > sizeof(buf))
free(msg);
if (level == FATAL || level == ERROR || level == WARNING)
fflush(g_logtostderr ? stderr : log_file);
fflush(log_file);
if (level == FATAL) {
fclose(log_file);
fflush(stdout);
Expand Down Expand Up @@ -196,11 +195,6 @@ static void log_info(void *logger, const char *file, int line,
va_end(argp);
}

static void logtostderr(void *logger)
{
g_logtostderr = true;
}

static void logtonull()
{
log_file = fopen("/dev/null", "w");
Expand Down Expand Up @@ -237,7 +231,6 @@ void logging_init(struct callbacks *cb, int argc, char **argv)
cb->log_error = log_error;
cb->log_warn = log_warn;
cb->log_info = log_info;
cb->logtostderr = logtostderr;
}

void logging_exit(struct callbacks *cb)
Expand Down
2 changes: 0 additions & 2 deletions psp_crr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ int main(int argc, char **argv)

/* Now parse the command line arguments */
flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);
flags_parser_dump(fp);
flags_parser_destroy(fp);

Expand Down
2 changes: 0 additions & 2 deletions psp_rr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ int main(int argc, char **argv)
fp = add_flags_tcp_rr(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);
flags_parser_dump(fp);
flags_parser_destroy(fp);

Expand Down
2 changes: 0 additions & 2 deletions psp_stream_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ int main(int argc, char **argv)
fp = add_flags_tcp_stream(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);

if (opts.enable_tcp_maerts) {
opts.enable_read = opts.client;
Expand Down
2 changes: 0 additions & 2 deletions tcp_crr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ int main(int argc, char **argv)

/* Now parse the command line arguments */
flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);
flags_parser_dump(fp);
flags_parser_destroy(fp);

Expand Down
2 changes: 0 additions & 2 deletions tcp_rr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ int main(int argc, char **argv)
fp = add_flags_tcp_rr(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);
flags_parser_dump(fp);
flags_parser_destroy(fp);

Expand Down
2 changes: 0 additions & 2 deletions tcp_stream_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ int main(int argc, char **argv)
fp = add_flags_tcp_stream(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);

if (opts.enable_tcp_maerts) {
opts.enable_read = opts.client;
Expand Down
2 changes: 0 additions & 2 deletions udp_rr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ int main(int argc, char **argv)
fp = add_flags_udp_rr(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);
flags_parser_dump(fp);
flags_parser_destroy(fp);

Expand Down
2 changes: 0 additions & 2 deletions udp_stream_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ int main(int argc, char **argv)
fp = add_flags_udp_stream(fp);

flags_parser_run(fp, argc, argv);
if (opts.logtostderr)
cb.logtostderr(cb.logger);

if (opts.client)
opts.enable_write = true;
Expand Down