diff --git a/src/debug.cpp b/src/debug.cpp index 3220c16c1..96d55599a 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -91,7 +91,6 @@ void log_msg(int level, const char *format, ...) #endif /* WIN32 */ va_list ap; - FILE *f = level >= LOG_LEVEL_INFO ? stdout : stderr; const char *color = ""; const char *ending = "\033[0m"; @@ -112,7 +111,7 @@ void log_msg(int level, const char *format, ...) } va_start(ap, format); - vfprintf(f, format, ap); + vfprintf(stderr, format, ap); va_end(ap); } diff --git a/src/debug.h b/src/debug.h index c895a5f8c..4b5dc6ddf 100644 --- a/src/debug.h +++ b/src/debug.h @@ -77,6 +77,11 @@ protected: private: int level; }; + +#define LOG(level) \ +if (level > log_level) ; \ +else Logger(level).Get() + #endif #endif diff --git a/src/keyboard_control.cpp b/src/keyboard_control.cpp index 0ee9573b6..b0b1916c3 100644 --- a/src/keyboard_control.cpp +++ b/src/keyboard_control.cpp @@ -156,7 +156,7 @@ void keyboard_control::usage() "\t* 0 - increase volume\n" << "\t/ 9 - decrease volume\n" << "\t m - mute/unmute\n" << - "\t v - toggle verbose mode\n" << + "\t v - increase verbosity level\n" << "\t h - show help\n" << "\n"; } diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 7d848d6c8..bd43834fd 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -1391,7 +1391,7 @@ static int reconfigure_if_needed(struct state_video_decoder *decoder, struct video_desc network_desc) { if (!video_desc_eq_excl_param(decoder->received_vid_desc, network_desc, PARAM_TILE_COUNT)) { - Logger(LOG_LEVEL_NOTICE).Get() << "New incoming video format detected: " << network_desc << endl; + LOG(LOG_LEVEL_NOTICE) << "New incoming video format detected: " << network_desc << endl; decoder->received_vid_desc = network_desc; #ifdef RECONFIGURE_IN_FUTURE_THREAD diff --git a/src/video_capture/DirectShowGrabber.cpp b/src/video_capture/DirectShowGrabber.cpp index 10e590252..aa75f777d 100644 --- a/src/video_capture/DirectShowGrabber.cpp +++ b/src/video_capture/DirectShowGrabber.cpp @@ -1159,7 +1159,7 @@ struct video_frame * vidcap_dshow_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(t, s->t0); if (seconds >= 5) { double fps = s->frames / seconds; - fprintf(stderr, "[dshow] %ld frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[dshow] %ld frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = t; s->frames = 0; } diff --git a/src/video_capture/aggregate.c b/src/video_capture/aggregate.c index b0bba2c95..c9c56073b 100644 --- a/src/video_capture/aggregate.c +++ b/src/video_capture/aggregate.c @@ -233,7 +233,7 @@ vidcap_aggregate_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[aggregate cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[aggregate cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/aja.cpp b/src/video_capture/aja.cpp index cf36dea81..5b8b908b0 100644 --- a/src/video_capture/aja.cpp +++ b/src/video_capture/aja.cpp @@ -560,7 +560,7 @@ struct video_frame *vidcap_state_aja::grab(struct audio_frame **audio) chrono::system_clock::time_point now = chrono::system_clock::now(); double seconds = chrono::duration_cast(now - mT0).count() / 1000000.0; if (seconds >= 5) { - cout << "[AJA] " << mFrames << " frames in " + LOG(LOG_LEVEL_INFO) << "[AJA] " << mFrames << " frames in " << seconds << " seconds = " << mFrames / seconds << " FPS\n"; mT0 = now; mFrames = 0; diff --git a/src/video_capture/bluefish444.cpp b/src/video_capture/bluefish444.cpp index dd86986d7..7ab8e5fe2 100644 --- a/src/video_capture/bluefish444.cpp +++ b/src/video_capture/bluefish444.cpp @@ -714,7 +714,7 @@ static void *worker(void *arg) double seconds = tv_diff(t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[Blue cap] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[Blue cap] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = t; s->frames = 0; } diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index a62258f91..247118761 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -1355,7 +1355,7 @@ vidcap_decklink_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[Decklink capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[Decklink capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = t; s->frames = 0; } diff --git a/src/video_capture/deltacast.cpp b/src/video_capture/deltacast.cpp index 0b8b13371..2a9bf0fd8 100644 --- a/src/video_capture/deltacast.cpp +++ b/src/video_capture/deltacast.cpp @@ -561,7 +561,7 @@ vidcap_deltacast_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[DELTACAST cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[DELTACAST cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/deltacast_dvi.cpp b/src/video_capture/deltacast_dvi.cpp index 92e612e5b..2ad016e31 100644 --- a/src/video_capture/deltacast_dvi.cpp +++ b/src/video_capture/deltacast_dvi.cpp @@ -759,7 +759,7 @@ vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[DELTACAST cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[DELTACAST cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/dvs.c b/src/video_capture/dvs.c index d3b7ebc5c..ce78ababe 100644 --- a/src/video_capture/dvs.c +++ b/src/video_capture/dvs.c @@ -590,7 +590,7 @@ struct video_frame *vidcap_dvs_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[DVS cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[DVS cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/import.cpp b/src/video_capture/import.cpp index 0c3a915cd..ef357c424 100644 --- a/src/video_capture/import.cpp +++ b/src/video_capture/import.cpp @@ -1245,7 +1245,7 @@ vidcap_import_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(cur_time, s->t0); if (seconds >= 5) { float fps = (s->frames - s->frames_prev) / seconds; - fprintf(stderr, "[import] %d frames in %g seconds = %g FPS\n", s->frames - s->frames_prev, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[import] %d frames in %g seconds = %g FPS\n", s->frames - s->frames_prev, seconds, fps); s->t0 = cur_time; s->frames_prev = s->frames; } diff --git a/src/video_capture/quicktime.c b/src/video_capture/quicktime.c index 5080bd1da..a42b52f94 100644 --- a/src/video_capture/quicktime.c +++ b/src/video_capture/quicktime.c @@ -211,7 +211,7 @@ qt_data_proc(SGChannel c, Ptr p, long len, long *offset, long chRefCon, double seconds = tv_diff(t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[QuickTime cap.] %d frames in %g seconds = %g FPS\n", s->frames, + log_msg(LOG_LEVEL_INFO, "[QuickTime cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = t; s->frames = 0; diff --git a/src/video_capture/screen_osx.c b/src/video_capture/screen_osx.c index 76444d90f..6ab8e8557 100644 --- a/src/video_capture/screen_osx.c +++ b/src/video_capture/screen_osx.c @@ -227,7 +227,7 @@ struct video_frame * vidcap_screen_osx_grab(void *state, struct audio_frame **au double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[screen capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[screen capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/screen_x11.c b/src/video_capture/screen_x11.c index 1b2376cb9..b6a824e9a 100644 --- a/src/video_capture/screen_x11.c +++ b/src/video_capture/screen_x11.c @@ -410,7 +410,7 @@ struct video_frame * vidcap_screen_x11_grab(void *state, struct audio_frame **au double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[screen capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[screen capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/swmix.cpp b/src/video_capture/swmix.cpp index f0061586f..2b04767e9 100644 --- a/src/video_capture/swmix.cpp +++ b/src/video_capture/swmix.cpp @@ -1310,7 +1310,7 @@ vidcap_swmix_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[swmix cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[swmix cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_capture/testcard2.c b/src/video_capture/testcard2.c index 4f9546f06..081ab243f 100644 --- a/src/video_capture/testcard2.c +++ b/src/video_capture/testcard2.c @@ -468,7 +468,7 @@ next_frame: double seconds = tv_diff(curr_time, s->t0); if (seconds >= 5) { float fps = (s->count - stat_count_prev) / seconds; - fprintf(stderr, "[testcard2] %d frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[testcard2] %d frames in %g seconds = %g FPS\n", (s->count - stat_count_prev), seconds, fps); s->t0 = curr_time; stat_count_prev = s->count; diff --git a/src/video_capture/v4l2.c b/src/video_capture/v4l2.c index 6b42bad4c..dcac18edb 100644 --- a/src/video_capture/v4l2.c +++ b/src/video_capture/v4l2.c @@ -683,7 +683,7 @@ struct video_frame * vidcap_v4l2_grab(void *state, struct audio_frame **audio) double seconds = tv_diff(t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[V4L2 capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[V4L2 capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = t; s->frames = 0; } diff --git a/src/video_display/aggregate.c b/src/video_display/aggregate.c index 5327ca8da..4eda8bb3c 100644 --- a/src/video_display/aggregate.c +++ b/src/video_display/aggregate.c @@ -377,7 +377,7 @@ void display_aggregate_put_audio_frame(void *state, struct audio_frame *frame) if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[aggregate disp.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[aggregate disp.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_display/bluefish444.cpp b/src/video_display/bluefish444.cpp index 8457680a7..845b3c66f 100644 --- a/src/video_display/bluefish444.cpp +++ b/src/video_display/bluefish444.cpp @@ -430,7 +430,7 @@ void *display_bluefish444_state::playback_loop() throw() double seconds = tv_diff(t, t0); if (seconds >= 5) { float fps = FrameCount / seconds; - fprintf(stderr, "[Blue disp] %d frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[Blue disp] %d frames in %g seconds = %g FPS\n", FrameCount, seconds, fps); t0 = t; FrameCount = 0; diff --git a/src/video_display/decklink.cpp b/src/video_display/decklink.cpp index f932981f1..e0cc50977 100644 --- a/src/video_display/decklink.cpp +++ b/src/video_display/decklink.cpp @@ -496,7 +496,7 @@ int display_decklink_putf(void *state, struct video_frame *frame, int nonblock) double seconds = tv_diff(tv, s->tv); if (seconds > 5) { double fps = (s->frames - s->frames_last) / seconds; - fprintf(stdout, "[Decklink display] %lu frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[Decklink display] %lu frames in %g seconds = %g FPS\n", s->frames - s->frames_last, seconds, fps); s->tv = tv; s->frames_last = s->frames; diff --git a/src/video_display/deltacast.cpp b/src/video_display/deltacast.cpp index a46bff236..0ad2bd347 100644 --- a/src/video_display/deltacast.cpp +++ b/src/video_display/deltacast.cpp @@ -252,7 +252,7 @@ int display_deltacast_putf(void *state, struct video_frame *frame, int nonblock) double seconds = tv_diff(tv, s->tv); if (seconds > 5) { double fps = s->frames / seconds; - fprintf(stdout, "[DELTACAST display] %lu frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[DELTACAST display] %lu frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->tv = tv; s->frames = 0; diff --git a/src/video_display/dvs.c b/src/video_display/dvs.c index 38b7a875d..e2fedb8c0 100644 --- a/src/video_display/dvs.c +++ b/src/video_display/dvs.c @@ -440,7 +440,7 @@ void display_dvs_run(void *arg) if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[DVS disp.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); + log_msg(LOG_LEVEL_INFO, "[DVS disp.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; } diff --git a/src/video_display/quicktime.c b/src/video_display/quicktime.c index e4d270c81..5cc509059 100644 --- a/src/video_display/quicktime.c +++ b/src/video_display/quicktime.c @@ -398,7 +398,7 @@ void display_quicktime_run(void *arg) double seconds = tv_diff(t, t0); if (seconds >= 5) { float fps = frames / seconds; - fprintf(stderr, "[QuickTime disp.] %d frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[QuickTime disp.] %d frames in %g seconds = %g FPS\n", frames, seconds, fps); t0 = t; frames = 0; diff --git a/src/video_display/sage.cpp b/src/video_display/sage.cpp index 0b3f50714..cdfbc4994 100644 --- a/src/video_display/sage.cpp +++ b/src/video_display/sage.cpp @@ -158,7 +158,7 @@ void display_sage_run(void *arg) double seconds = tv_diff(s->t, s->t0); if (seconds >= 5) { float fps = s->frames / seconds; - fprintf(stderr, "[SAGE] %d frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[SAGE] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->t0 = s->t; s->frames = 0; diff --git a/src/video_display/sdl.cpp b/src/video_display/sdl.cpp index 103262c63..0dc96d27b 100644 --- a/src/video_display/sdl.cpp +++ b/src/video_display/sdl.cpp @@ -382,7 +382,7 @@ free_frame: double seconds = tv_diff(tv, s->tv); if (seconds > 5) { double fps = s->frames / seconds; - fprintf(stdout, "[SDL] %d frames in %g seconds = %g FPS\n", + log_msg(LOG_LEVEL_INFO, "[SDL] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); s->tv = tv; s->frames = 0;