From 61b6324ee902f48da4c4e6a76b3123e8768b4a9f Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 5 Feb 2022 14:06:03 +0100 Subject: [PATCH] Remove LOGC() It is not clear when to use LOGC() rather than LOGE(). Always use LOGE(). Moreover, enum sc_log_level has no "critical" log level. --- app/src/controller.c | 2 +- app/src/demuxer.c | 2 +- app/src/file_pusher.c | 2 +- app/src/receiver.c | 2 +- app/src/recorder.c | 2 +- app/src/scrcpy.c | 4 ++-- app/src/screen.c | 8 ++++---- app/src/sys/unix/process.c | 2 +- app/src/usb/aoa_hid.c | 2 +- app/src/usb/scrcpy_otg.c | 2 +- app/src/util/log.h | 3 +-- app/src/util/net.c | 2 +- app/src/util/thread.c | 12 ++++++------ app/src/v4l2_sink.c | 2 +- 14 files changed, 23 insertions(+), 24 deletions(-) diff --git a/app/src/controller.c b/app/src/controller.c index 626a5e30..cdf53edb 100644 --- a/app/src/controller.c +++ b/app/src/controller.c @@ -113,7 +113,7 @@ sc_controller_start(struct sc_controller *controller) { bool ok = sc_thread_create(&controller->thread, run_controller, "scrcpy-ctl", controller); if (!ok) { - LOGC("Could not start controller thread"); + LOGE("Could not start controller thread"); return false; } diff --git a/app/src/demuxer.c b/app/src/demuxer.c index c683dfe0..bebdb6d6 100644 --- a/app/src/demuxer.c +++ b/app/src/demuxer.c @@ -276,7 +276,7 @@ sc_demuxer_start(struct sc_demuxer *demuxer) { bool ok = sc_thread_create(&demuxer->thread, run_demuxer, "scrcpy-demuxer", demuxer); if (!ok) { - LOGC("Could not start demuxer thread"); + LOGE("Could not start demuxer thread"); return false; } return true; diff --git a/app/src/file_pusher.c b/app/src/file_pusher.c index cbbeb2d7..f6757870 100644 --- a/app/src/file_pusher.c +++ b/app/src/file_pusher.c @@ -156,7 +156,7 @@ sc_file_pusher_start(struct sc_file_pusher *fp) { bool ok = sc_thread_create(&fp->thread, run_file_pusher, "scrcpy-file", fp); if (!ok) { - LOGC("Could not start file_pusher thread"); + LOGE("Could not start file_pusher thread"); return false; } diff --git a/app/src/receiver.c b/app/src/receiver.c index 1e25536e..0376948d 100644 --- a/app/src/receiver.c +++ b/app/src/receiver.c @@ -114,7 +114,7 @@ receiver_start(struct receiver *receiver) { bool ok = sc_thread_create(&receiver->thread, run_receiver, "scrcpy-receiver", receiver); if (!ok) { - LOGC("Could not start receiver thread"); + LOGE("Could not start receiver thread"); return false; } diff --git a/app/src/recorder.c b/app/src/recorder.c index 2a82e172..b14b6050 100644 --- a/app/src/recorder.c +++ b/app/src/recorder.c @@ -290,7 +290,7 @@ sc_recorder_open(struct sc_recorder *recorder, const AVCodec *input_codec) { ok = sc_thread_create(&recorder->thread, run_recorder, "scrcpy-recorder", recorder); if (!ok) { - LOGC("Could not start recorder thread"); + LOGE("Could not start recorder thread"); goto error_avio_close; } diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index c846ee18..dc4ac25a 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -269,7 +269,7 @@ scrcpy(struct scrcpy_options *options) { // Minimal SDL initialization if (SDL_Init(SDL_INIT_EVENTS)) { - LOGC("Could not initialize SDL: %s", SDL_GetError()); + LOGE("Could not initialize SDL: %s", SDL_GetError()); return false; } @@ -341,7 +341,7 @@ scrcpy(struct scrcpy_options *options) { // Initialize SDL video in addition if display is enabled if (options->display && SDL_Init(SDL_INIT_VIDEO)) { - LOGC("Could not initialize SDL: %s", SDL_GetError()); + LOGE("Could not initialize SDL: %s", SDL_GetError()); goto end; } diff --git a/app/src/screen.c b/app/src/screen.c index c62920bc..98626909 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -423,14 +423,14 @@ sc_screen_init(struct sc_screen *screen, screen->window = SDL_CreateWindow(params->window_title, 0, 0, 0, 0, window_flags); if (!screen->window) { - LOGC("Could not create window: %s", SDL_GetError()); + LOGE("Could not create window: %s", SDL_GetError()); goto error_destroy_fps_counter; } screen->renderer = SDL_CreateRenderer(screen->window, -1, SDL_RENDERER_ACCELERATED); if (!screen->renderer) { - LOGC("Could not create renderer: %s", SDL_GetError()); + LOGE("Could not create renderer: %s", SDL_GetError()); goto error_destroy_window; } @@ -479,7 +479,7 @@ sc_screen_init(struct sc_screen *screen, params->frame_size.height); screen->texture = create_texture(screen); if (!screen->texture) { - LOGC("Could not create texture: %s", SDL_GetError()); + LOGE("Could not create texture: %s", SDL_GetError()); goto error_destroy_renderer; } @@ -666,7 +666,7 @@ prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) { screen->frame_size.width, screen->frame_size.height); screen->texture = create_texture(screen); if (!screen->texture) { - LOGC("Could not create texture: %s", SDL_GetError()); + LOGE("Could not create texture: %s", SDL_GetError()); return false; } } diff --git a/app/src/sys/unix/process.c b/app/src/sys/unix/process.c index cb82f3a9..cef227ed 100644 --- a/app/src/sys/unix/process.c +++ b/app/src/sys/unix/process.c @@ -176,7 +176,7 @@ sc_process_execute_p(const char *const argv[], sc_pid *pid, unsigned flags, bool sc_process_terminate(pid_t pid) { if (pid <= 0) { - LOGC("Requested to kill %d, this is an error. Please report the bug.\n", + LOGE("Requested to kill %d, this is an error. Please report the bug.\n", (int) pid); abort(); } diff --git a/app/src/usb/aoa_hid.c b/app/src/usb/aoa_hid.c index ca10934a..57296bfc 100644 --- a/app/src/usb/aoa_hid.c +++ b/app/src/usb/aoa_hid.c @@ -278,7 +278,7 @@ sc_aoa_start(struct sc_aoa *aoa) { bool ok = sc_thread_create(&aoa->thread, run_aoa_thread, "scrcpy-aoa", aoa); if (!ok) { - LOGC("Could not start AOA thread"); + LOGE("Could not start AOA thread"); return false; } diff --git a/app/src/usb/scrcpy_otg.c b/app/src/usb/scrcpy_otg.c index e27a3605..e39ab27a 100644 --- a/app/src/usb/scrcpy_otg.c +++ b/app/src/usb/scrcpy_otg.c @@ -56,7 +56,7 @@ scrcpy_otg(struct scrcpy_options *options) { // Minimal SDL initialization if (SDL_Init(SDL_INIT_EVENTS)) { - LOGC("Could not initialize SDL: %s", SDL_GetError()); + LOGE("Could not initialize SDL: %s", SDL_GetError()); return false; } diff --git a/app/src/util/log.h b/app/src/util/log.h index e3efdbe5..94787347 100644 --- a/app/src/util/log.h +++ b/app/src/util/log.h @@ -15,10 +15,9 @@ #define LOGI(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) #define LOGW(...) SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) #define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) -#define LOGC(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) #define LOG_OOM() \ - LOGC("OOM: %s:%d %s()", __FILE__, __LINE__, __func__) + LOGE("OOM: %s:%d %s()", __FILE__, __LINE__, __func__) void sc_set_log_level(enum sc_log_level level); diff --git a/app/src/util/net.c b/app/src/util/net.c index b18566be..b1aa7445 100644 --- a/app/src/util/net.c +++ b/app/src/util/net.c @@ -33,7 +33,7 @@ net_init(void) { WSADATA wsa; int res = WSAStartup(MAKEWORD(2, 2), &wsa) < 0; if (res < 0) { - LOGC("WSAStartup failed with error %d", res); + LOGE("WSAStartup failed with error %d", res); return false; } #endif diff --git a/app/src/util/thread.c b/app/src/util/thread.c index c6e6b81e..0d098b3f 100644 --- a/app/src/util/thread.c +++ b/app/src/util/thread.c @@ -54,7 +54,7 @@ sc_mutex_lock(sc_mutex *mutex) { int r = SDL_LockMutex(mutex->mutex); #ifndef NDEBUG if (r) { - LOGC("Could not lock mutex: %s", SDL_GetError()); + LOGE("Could not lock mutex: %s", SDL_GetError()); abort(); } @@ -74,7 +74,7 @@ sc_mutex_unlock(sc_mutex *mutex) { int r = SDL_UnlockMutex(mutex->mutex); #ifndef NDEBUG if (r) { - LOGC("Could not lock mutex: %s", SDL_GetError()); + LOGE("Could not lock mutex: %s", SDL_GetError()); abort(); } #else @@ -118,7 +118,7 @@ sc_cond_wait(sc_cond *cond, sc_mutex *mutex) { int r = SDL_CondWait(cond->cond, mutex->mutex); #ifndef NDEBUG if (r) { - LOGC("Could not wait on condition: %s", SDL_GetError()); + LOGE("Could not wait on condition: %s", SDL_GetError()); abort(); } @@ -140,7 +140,7 @@ sc_cond_timedwait(sc_cond *cond, sc_mutex *mutex, sc_tick deadline) { int r = SDL_CondWaitTimeout(cond->cond, mutex->mutex, ms); #ifndef NDEBUG if (r < 0) { - LOGC("Could not wait on condition with timeout: %s", SDL_GetError()); + LOGE("Could not wait on condition with timeout: %s", SDL_GetError()); abort(); } @@ -156,7 +156,7 @@ sc_cond_signal(sc_cond *cond) { int r = SDL_CondSignal(cond->cond); #ifndef NDEBUG if (r) { - LOGC("Could not signal a condition: %s", SDL_GetError()); + LOGE("Could not signal a condition: %s", SDL_GetError()); abort(); } #else @@ -169,7 +169,7 @@ sc_cond_broadcast(sc_cond *cond) { int r = SDL_CondBroadcast(cond->cond); #ifndef NDEBUG if (r) { - LOGC("Could not broadcast a condition: %s", SDL_GetError()); + LOGE("Could not broadcast a condition: %s", SDL_GetError()); abort(); } #else diff --git a/app/src/v4l2_sink.c b/app/src/v4l2_sink.c index 7675fd92..9a0011f2 100644 --- a/app/src/v4l2_sink.c +++ b/app/src/v4l2_sink.c @@ -274,7 +274,7 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) { LOGD("Starting v4l2 thread"); ok = sc_thread_create(&vs->thread, run_v4l2_sink, "scrcpy-v4l2", vs); if (!ok) { - LOGC("Could not start v4l2 thread"); + LOGE("Could not start v4l2 thread"); goto error_av_packet_free; }