-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move log level conversion to log API
- Loading branch information
Showing
4 changed files
with
39 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "log.h" | ||
|
||
#include <assert.h> | ||
|
||
static SDL_LogPriority | ||
log_level_sc_to_sdl(enum sc_log_level level) { | ||
switch (level) { | ||
case SC_LOG_LEVEL_VERBOSE: | ||
return SDL_LOG_PRIORITY_VERBOSE; | ||
case SC_LOG_LEVEL_DEBUG: | ||
return SDL_LOG_PRIORITY_DEBUG; | ||
case SC_LOG_LEVEL_INFO: | ||
return SDL_LOG_PRIORITY_INFO; | ||
case SC_LOG_LEVEL_WARN: | ||
return SDL_LOG_PRIORITY_WARN; | ||
case SC_LOG_LEVEL_ERROR: | ||
return SDL_LOG_PRIORITY_ERROR; | ||
default: | ||
assert(!"unexpected log level"); | ||
return SDL_LOG_PRIORITY_INFO; | ||
} | ||
} | ||
|
||
void | ||
sc_set_log_level(enum sc_log_level level) { | ||
SDL_LogPriority sdl_log = log_level_sc_to_sdl(level); | ||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, sdl_log); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
#ifndef LOG_H | ||
#define LOG_H | ||
#ifndef SC_LOG_H | ||
#define SC_LOG_H | ||
|
||
#include "common.h" | ||
|
||
#include <SDL2/SDL_log.h> | ||
|
||
#include "scrcpy.h" | ||
|
||
#define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) | ||
#define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) | ||
#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__) | ||
|
||
void | ||
sc_set_log_level(enum sc_log_level level); | ||
|
||
#endif |