diff --git a/src/aja_common.hpp b/src/aja_common.hpp index 5fbeda8bd..f0adffa8b 100644 --- a/src/aja_common.hpp +++ b/src/aja_common.hpp @@ -44,6 +44,9 @@ class CNTV2Card; #ifdef _MSC_VER #define log_msg(x, ...) fprintf(stderr, __VA_ARGS__) +#define bug_msg(x, ...) \ + log_msg(x, __VA_ARGS__); \ + log_msg(x, " Please report a bug if you reach here.\n") #define color_printf printf #undef LOG #include diff --git a/src/audio/capture/alsa.c b/src/audio/capture/alsa.c index 92c22b14d..3296e0836 100644 --- a/src/audio/capture/alsa.c +++ b/src/audio/capture/alsa.c @@ -47,7 +47,6 @@ /* Use the newer ALSA API */ #define ALSA_PCM_NEW_HW_PARAMS_API -#include "config.h" #include "config_unix.h" #include "host.h" @@ -197,8 +196,8 @@ static void * audio_cap_alsa_init(struct module *parent, const char *cfg) } } if (s->frame.bps == 0) { - log_msg(LOG_LEVEL_ERROR, MOD_NAME "Cannot find suitable sample format, " - "please contact %s.\n", PACKAGE_BUGREPORT); + bug_msg(LOG_LEVEL_ERROR, MOD_NAME + "Cannot find suitable sample format. "); goto error; } } diff --git a/src/audio/playback/jack.c b/src/audio/playback/jack.c index ddbfc81ba..cbbd69ff3 100644 --- a/src/audio/playback/jack.c +++ b/src/audio/playback/jack.c @@ -86,10 +86,10 @@ static int jack_samplerate_changed_callback(jack_nframes_t nframes, void *arg) struct state_jack_playback *s = (struct state_jack_playback *) arg; if (s->jack_sample_rate != 0) { - log_msg(LOG_LEVEL_WARNING, "JACK sample rate changed from %d to %d. " + bug_msg(LOG_LEVEL_WARNING, "JACK sample rate changed from %d to %d. " "Runtime change is not supported in UG and will likely " - "cause malfunctioning. If so, pleaser report to %s\n.", - s->jack_sample_rate, nframes, PACKAGE_BUGREPORT); + "cause malfunctioning. ", + s->jack_sample_rate, nframes); } else { log_msg(LOG_LEVEL_NOTICE, MOD_NAME "Sample rate changed to: %d\n", nframes); diff --git a/src/audio/utils.cpp b/src/audio/utils.cpp index 6b489ca05..82054b938 100644 --- a/src/audio/utils.cpp +++ b/src/audio/utils.cpp @@ -37,7 +37,6 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" #include "config_unix.h" #include "config_win32.h" #endif // HAVE_CONFIG_H @@ -57,9 +56,9 @@ #include "utils/macros.h" #include "utils/misc.h" -#ifdef WORDS_BIGENDIAN -#error "This code will not run with a big-endian machine. Please report a bug to " PACKAGE_BUGREPORT " if you reach here." -#endif // WORDS_BIGENDIAN +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#error "This code will not run with a big-endian machine. Please report a bug if you reach here." +#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ using std::clamp; using std::max; diff --git a/src/debug.cpp b/src/debug.cpp index 2d5ad8449..04bb81a02 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -373,15 +373,21 @@ void debug_file_dump(const char *key, void (*serialize)(const void *data, FILE * * MOD_NAME. Should end with either ' ' or '\n' (what fits the caller better). */ void -bug_msg(int level, const char *msg) +bug_msg(int level, const char *format, ...) { - log_msg(level, + char fmt_adj[STR_LEN]; + snprintf_ch(fmt_adj, "%sPlease report a bug" #ifdef PACKAGE_BUGREPORT " to " PACKAGE_BUGREPORT #endif // defined PACKAGE_BUGREPORT " if you reach here.\n", - msg); + format); + + va_list ap; + va_start(ap, format); + log_vprintf(level, fmt_adj, ap); + va_end(ap); } Log_output::Log_output(){ diff --git a/src/debug.h b/src/debug.h index 5fb57aade..f329bd7eb 100644 --- a/src/debug.h +++ b/src/debug.h @@ -101,7 +101,7 @@ bool parse_log_cfg(const char *conf_str, bool *logger_skip_repeats, enum log_timestamp_mode *show_timestamps); -void bug_msg(int level, const char *msg); +void bug_msg(int level, const char *format, ...) __attribute__((format (printf, 2, 3))); #ifdef __cplusplus } diff --git a/src/utils/windows.c b/src/utils/windows.c index cebb56d11..c1c09bb8b 100644 --- a/src/utils/windows.c +++ b/src/utils/windows.c @@ -189,7 +189,10 @@ const char *win_wstr_to_str(const wchar_t *wstr) { int ret = WideCharToMultiByte(CP_UTF8, 0, wstr, -1 /* NULL-terminated */, res, sizeof res - 1, NULL, NULL); if (ret == 0) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - log_msg(LOG_LEVEL_ERROR, "win_wstr_to_str: Insufficient buffer length %zd, please report to %s!\n", sizeof res, PACKAGE_BUGREPORT); + bug_msg( + LOG_LEVEL_ERROR, + "win_wstr_to_str: Insufficient buffer length %zd. ", + sizeof res); } else { log_msg(LOG_LEVEL_ERROR, "win_wstr_to_str: %s\n", get_win32_error(GetLastError())); } diff --git a/src/video_capture/DirectShowGrabber.cpp b/src/video_capture/DirectShowGrabber.cpp index e06f22e17..9765465cb 100644 --- a/src/video_capture/DirectShowGrabber.cpp +++ b/src/video_capture/DirectShowGrabber.cpp @@ -575,10 +575,12 @@ static bool process_args(struct vidcap_dshow_state *s, char *init_fmt) { s->desc.color_spec = get_ug_from_subtype_name(token); } if (s->desc.color_spec == VIDEO_CODEC_NONE) { - log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unsupported video format: %s. " - "Please contact us via %s if you need support for this codec.\n", - token, PACKAGE_BUGREPORT); - return false; + bug_msg(LOG_LEVEL_ERROR, + MOD_NAME + "Unsupported video " + "format: %s. ", + token); + return false; } } break; diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index 0c26a0a68..a17a718dc 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -75,7 +75,6 @@ #include "audio/utils.h" #include "compat/htonl.h" #include "compat/strings.h" -#include "config.h" // for PACKAGE_BUGREPORT #include "debug.h" #include "host.h" #include "lib_common.h" @@ -993,7 +992,9 @@ static HRESULT set_display_mode_properties(struct vidcap_decklink_state *s, stru s->next_frame_time = static_cast(std::chrono::microseconds::period::den / s->frame->fps); // in microseconds switch(displayMode->GetFieldDominance()) { case bmdLowerFieldFirst: - log_msg(LOG_LEVEL_WARNING, MOD_NAME "Lower field first format detected, fields can be switched! If so, please report a bug to " PACKAGE_BUGREPORT "\n"); + bug_msg(LOG_LEVEL_WARNING, + MOD_NAME "Lower field first format detected, " + "fields can be switched! "); // fall through case bmdUpperFieldFirst: s->frame->interlacing = INTERLACED_MERGED; diff --git a/src/video_display/aja.cpp b/src/video_display/aja.cpp index 3b77a62c7..4895302ea 100644 --- a/src/video_display/aja.cpp +++ b/src/video_display/aja.cpp @@ -39,9 +39,6 @@ * The use of ping-pong buffer technique is based on NTV2LLBurn. */ -#ifdef HAVE_CONFIG_H -#include "config.h" // for PACKAGE_BUGREPORT -#endif // HAVE_CONFIG_H #include "config_msvc.h" #include "debug.h" @@ -552,8 +549,12 @@ void display::RouteOutputSignal () "Connect from CSC", NOOP); } } else { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Routing for " << NTV2OutputDestinationToString(mConf.outputDestination) - << " may be incorrect. Please report to " PACKAGE_BUGREPORT ".\n" << endl; + bug_msg(LOG_LEVEL_WARNING, + MOD_NAME + "Routing for %s may be incorrect. ", + NTV2OutputDestinationToString( + mConf.outputDestination) + .c_str()); CHECK_EX(mDevice.Connect(::GetOutputDestInputXpt(mConf.outputDestination), fbIsRGB ? cscVidOutXpt : fsVidOutXpt), "Connect from CSC or frame store", NOOP); } diff --git a/src/video_display/decklink.cpp b/src/video_display/decklink.cpp index 58e2d29c3..8438390e3 100644 --- a/src/video_display/decklink.cpp +++ b/src/video_display/decklink.cpp @@ -76,7 +76,6 @@ #include "blackmagic_common.hpp" #include "compat/htonl.h" #include "compat/strings.h" -#include "config.h" // for PACKAGE_BUGREPORT #include "debug.h" #include "host.h" #include "lib_common.h" @@ -870,7 +869,11 @@ static BMDDisplayMode get_mode(IDeckLinkOutput *deckLinkOutput, struct video_des if (dominance == bmdLowerFieldFirst || dominance == bmdUpperFieldFirst) { if (dominance == bmdLowerFieldFirst) { - log_msg(LOG_LEVEL_WARNING, MOD_NAME "Lower field first format detected, fields can be switched! If so, please report a bug to " PACKAGE_BUGREPORT "\n"); + bug_msg( + LOG_LEVEL_WARNING, MOD_NAME + "Lower field first format " + "detected, fields can be " + "switched! "); } interlaced = true; } else { // progressive, psf, unknown diff --git a/src/vo_postprocess/text.c b/src/vo_postprocess/text.c index c57a2a9df..6a8f5b65e 100644 --- a/src/vo_postprocess/text.c +++ b/src/vo_postprocess/text.c @@ -43,7 +43,7 @@ #ifdef HAVE_CONFIG_H -#include "config.h" +#include "config.h" // WAND7 #include "config_unix.h" #include "config_win32.h" #endif /* HAVE_CONFIG_H */ @@ -229,8 +229,7 @@ text_postprocess_reconfigure(void *state, struct video_desc desc) color_outline = "#EB8080FF"; colorspace = "UYVY"; } else { - log_msg(LOG_LEVEL_ERROR, "[text vo_pp.] Codec not supported! Please report to " - PACKAGE_BUGREPORT ".\n"); + bug_msg(LOG_LEVEL_ERROR, "[text vo_pp.] Codec not supported! "); return false; }