mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
util: add wlr_ prefix to log symbols
This commit is contained in:
parent
ffc8780893
commit
7cbef15206
98 changed files with 631 additions and 629 deletions
26
util/log.c
26
util/log.c
|
|
@ -9,16 +9,16 @@
|
|||
#include <wlr/util/log.h>
|
||||
|
||||
static bool colored = true;
|
||||
static log_importance_t log_importance = L_ERROR;
|
||||
static enum wlr_log_importance log_importance = WLR_ERROR;
|
||||
|
||||
static const char *verbosity_colors[] = {
|
||||
[L_SILENT] = "",
|
||||
[L_ERROR ] = "\x1B[1;31m",
|
||||
[L_INFO ] = "\x1B[1;34m",
|
||||
[L_DEBUG ] = "\x1B[1;30m",
|
||||
[WLR_SILENT] = "",
|
||||
[WLR_ERROR ] = "\x1B[1;31m",
|
||||
[WLR_INFO ] = "\x1B[1;34m",
|
||||
[WLR_DEBUG ] = "\x1B[1;30m",
|
||||
};
|
||||
|
||||
static void log_stderr(log_importance_t verbosity, const char *fmt,
|
||||
static void log_stderr(enum wlr_log_importance verbosity, const char *fmt,
|
||||
va_list args) {
|
||||
if (verbosity > log_importance) {
|
||||
return;
|
||||
|
|
@ -33,7 +33,7 @@ static void log_stderr(log_importance_t verbosity, const char *fmt,
|
|||
strftime(buffer, sizeof(buffer), "%F %T - ", tm_info);
|
||||
fprintf(stderr, "%s", buffer);
|
||||
|
||||
unsigned c = (verbosity < L_LAST) ? verbosity : L_LAST - 1;
|
||||
unsigned c = (verbosity < WLR_LOG_IMPORTANCE_LAST) ? verbosity : WLR_LOG_IMPORTANCE_LAST - 1;
|
||||
|
||||
if (colored && isatty(STDERR_FILENO)) {
|
||||
fprintf(stderr, "%s", verbosity_colors[c]);
|
||||
|
|
@ -47,10 +47,10 @@ static void log_stderr(log_importance_t verbosity, const char *fmt,
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static log_callback_t log_callback = log_stderr;
|
||||
static wlr_log_func_t log_callback = log_stderr;
|
||||
|
||||
void wlr_log_init(log_importance_t verbosity, log_callback_t callback) {
|
||||
if (verbosity < L_LAST) {
|
||||
void wlr_log_init(enum wlr_log_importance verbosity, wlr_log_func_t callback) {
|
||||
if (verbosity < WLR_LOG_IMPORTANCE_LAST) {
|
||||
log_importance = verbosity;
|
||||
}
|
||||
if (callback) {
|
||||
|
|
@ -58,11 +58,11 @@ void wlr_log_init(log_importance_t verbosity, log_callback_t callback) {
|
|||
}
|
||||
}
|
||||
|
||||
void _wlr_vlog(log_importance_t verbosity, const char *fmt, va_list args) {
|
||||
void _wlr_vlog(enum wlr_log_importance verbosity, const char *fmt, va_list args) {
|
||||
log_callback(verbosity, fmt, args);
|
||||
}
|
||||
|
||||
void _wlr_log(log_importance_t verbosity, const char *fmt, ...) {
|
||||
void _wlr_log(enum wlr_log_importance verbosity, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
log_callback(verbosity, fmt, args);
|
||||
|
|
@ -74,7 +74,7 @@ void _wlr_log(log_importance_t verbosity, const char *fmt, ...) {
|
|||
// e.g. '/src/build/wlroots/backend/wayland/backend.c' and
|
||||
// '../backend/wayland/backend.c' will both be stripped to
|
||||
// 'backend/wayland/backend.c'
|
||||
const char *wlr_strip_path(const char *filepath) {
|
||||
const char *_wlr_strip_path(const char *filepath) {
|
||||
static int srclen = sizeof(WLR_SRC_DIR);
|
||||
if (strstr(filepath, WLR_SRC_DIR) == filepath) {
|
||||
filepath += srclen;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue