diff --git a/common/av_log.c b/common/av_log.c index 0ee39b3022..a6d51f88e3 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -69,7 +69,7 @@ static bool log_print_prefix = true; static int av_log_level_to_mp_level(int av_level) { if (av_level > AV_LOG_VERBOSE) - return MSGL_DBG2; + return MSGL_DEBUG; if (av_level > AV_LOG_INFO) return MSGL_V; if (av_level > AV_LOG_WARNING) diff --git a/common/msg.c b/common/msg.c index 8563cadc65..3a6f3a14e3 100644 --- a/common/msg.c +++ b/common/msg.c @@ -114,6 +114,7 @@ static void update_loglevel(struct mp_log *log) pthread_mutex_unlock(&mp_msg_lock); } +// Return whether the message at this verbosity level would be actually printed. bool mp_msg_test_log(struct mp_log *log, int lev) { if (mp_msg_mute || !log->root) @@ -136,7 +137,7 @@ static int mp_msg_docolor(void) static void set_msg_color(FILE* stream, int lev) { - static const int v_colors[] = {9, 1, 3, 3, -1, -1, 2, 8, 8, 8, 9}; + static const int v_colors[] = {9, 1, 3, -1, -1, 2, 8, 8, -1}; if (mp_msg_docolor()) terminal_set_foreground_color(stream, v_colors[lev]); } @@ -272,8 +273,8 @@ static const char *level_names[] = { [MSGL_INFO] = "info", [MSGL_STATUS] = "status", [MSGL_V] = "v", - [MSGL_DBG2] = "debug", - [MSGL_DBG5] = "trace", + [MSGL_DEBUG] = "debug", + [MSGL_TRACE] = "trace", }; int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level) diff --git a/common/msg.h b/common/msg.h index 41fcbbe3e9..fd0e176273 100644 --- a/common/msg.h +++ b/common/msg.h @@ -37,18 +37,17 @@ extern int mp_smode; // slave mode compatibility glue extern struct mp_log *const mp_null_log; // Verbosity levels. -#define MSGL_FATAL 0 // will exit/abort (note: msg.c doesn't exit or abort) -#define MSGL_ERR 1 // continues -#define MSGL_WARN 2 // only warning -#define MSGL_HINT 3 // (to be phased out) -#define MSGL_INFO 4 // -quiet -#define MSGL_STATUS 5 // exclusively for the playback status line -#define MSGL_V 6 // -v -#define MSGL_DBG2 7 // -v -v -#define MSGL_DBG3 8 // ... -#define MSGL_DBG4 9 // .... -#define MSGL_DBG5 10 // ..... -#define MSGL_SMODE 11 // old slave mode (-identify) +enum { + MSGL_FATAL, // will exit/abort (note: msg.c doesn't exit or abort) + MSGL_ERR, // continues + MSGL_WARN, // only warning + MSGL_INFO, // -quiet + MSGL_STATUS, // exclusively for the playback status line + MSGL_V, // -v + MSGL_DEBUG, // -v -v + MSGL_TRACE, // -v -v -v + MSGL_SMODE, // old slave mode (-identify) +}; struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, const char *name); @@ -59,6 +58,15 @@ void mp_msg_log_va(struct mp_log *log, int lev, const char *format, va_list va); bool mp_msg_test_log(struct mp_log *log, int lev); +// Convenience macros. +#define mp_fatal(log, ...) mp_msg_log(log, MSGL_FATAL, __VA_ARGS__) +#define mp_err(log, ...) mp_msg_log(log, MSGL_ERR, __VA_ARGS__) +#define mp_warn(log, ...) mp_msg_log(log, MSGL_WARN, __VA_ARGS__) +#define mp_info(log, ...) mp_msg_log(log, MSGL_INFO, __VA_ARGS__) +#define mp_verbose(log, ...) mp_msg_log(log, MSGL_V, __VA_ARGS__) +#define mp_dbg(log, ...) mp_msg_log(log, MSGL_DEBUG, __VA_ARGS__) +#define mp_trace(log, ...) mp_msg_log(log, MSGL_TRACE, __VA_ARGS__) + // Convenience macros, typically called with a pointer to a context struct // as first argument, which has a "struct mp_log log;" member. @@ -69,18 +77,10 @@ bool mp_msg_test_log(struct mp_log *log, int lev); #define MP_WARN(obj, ...) MP_MSG(obj, MSGL_WARN, __VA_ARGS__) #define MP_INFO(obj, ...) MP_MSG(obj, MSGL_INFO, __VA_ARGS__) #define MP_VERBOSE(obj, ...) MP_MSG(obj, MSGL_V, __VA_ARGS__) -#define MP_DBG(obj, ...) MP_MSG(obj, MSGL_DBG2, __VA_ARGS__) -#define MP_TRACE(obj, ...) MP_MSG(obj, MSGL_DBG5, __VA_ARGS__) +#define MP_DBG(obj, ...) MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__) +#define MP_TRACE(obj, ...) MP_MSG(obj, MSGL_TRACE, __VA_ARGS__) #define MP_SMODE(obj, ...) MP_MSG(obj, MSGL_SMODE, __VA_ARGS__) -#define mp_fatal(log, ...) mp_msg_log(log, MSGL_FATAL, __VA_ARGS__) -#define mp_err(log, ...) mp_msg_log(log, MSGL_ERR, __VA_ARGS__) -#define mp_warn(log, ...) mp_msg_log(log, MSGL_WARN, __VA_ARGS__) -#define mp_info(log, ...) mp_msg_log(log, MSGL_INFO, __VA_ARGS__) -#define mp_verbose(log, ...) mp_msg_log(log, MSGL_V, __VA_ARGS__) -#define mp_dbg(log, ...) mp_msg_log(log, MSGL_DBG2, __VA_ARGS__) -#define mp_trace(log, ...) mp_msg_log(log, MSGL_DBG5, __VA_ARGS__) - struct mpv_global; void mp_msg_init(struct mpv_global *global); void mp_msg_uninit(struct mpv_global *global); diff --git a/demux/ebml.c b/demux/ebml.c index 6565b9c3a9..fbc9998602 100644 --- a/demux/ebml.c +++ b/demux/ebml.c @@ -698,7 +698,7 @@ int ebml_read_element(struct stream *s, struct ebml_parse_ctx *ctx, void *target, const struct ebml_elem_desc *desc) { ctx->has_errors = false; - int msglevel = ctx->no_error_messages ? MSGL_DBG2 : MSGL_WARN; + int msglevel = ctx->no_error_messages ? MSGL_DEBUG : MSGL_WARN; uint64_t length = ebml_read_length(s, &ctx->bytes_read); if (s->eof) { MP_MSG(ctx, msglevel, "Unexpected end of file " diff --git a/input/input.c b/input/input.c index fc3e282287..751651f4bf 100644 --- a/input/input.c +++ b/input/input.c @@ -1455,7 +1455,7 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, int msgl = MSGL_WARN; if (n == 1 && (keys[0] == MP_KEY_MOUSE_MOVE || keys[0] == MP_KEY_MOUSE_LEAVE)) - msgl = MSGL_DBG2; + msgl = MSGL_DEBUG; char *key_buf = get_key_combo_name(keys, n); MP_MSG(ictx, msgl, "No bind found for key '%s'.\n", key_buf); talloc_free(key_buf); @@ -1464,7 +1464,7 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, mp_cmd_t *ret = mp_input_parse_cmd(ictx, bstr0(cmd->cmd), cmd->location); if (ret) { ret->input_section = cmd->owner->section; - if (mp_msg_test_log(ictx->log, MSGL_DBG2)) { + if (mp_msg_test_log(ictx->log, MSGL_DEBUG)) { char *keyname = get_key_combo_name(keys, n); MP_DBG(ictx, "key '%s' -> '%s' in '%s'\n", keyname, cmd->cmd, ret->input_section); @@ -1578,7 +1578,7 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale) if (unmod >= 32 && unmod < MP_KEY_BASE) code &= ~MP_KEY_MODIFIER_SHIFT; - if (mp_msg_test_log(ictx->log, MSGL_DBG2)) { + if (mp_msg_test_log(ictx->log, MSGL_DEBUG)) { int noflags = code & ~(MP_KEY_STATE_DOWN | MP_KEY_STATE_UP); char *key = get_key_name(noflags, NULL); MP_DBG(ictx, "key code=%#x '%s'%s%s\n", diff --git a/player/lua.c b/player/lua.c index a3e119a76a..65d58ff5e8 100644 --- a/player/lua.c +++ b/player/lua.c @@ -260,7 +260,7 @@ static const char *log_level[] = { [MSGL_WARN] = "warn", [MSGL_INFO] = "info", [MSGL_V] = "verbose", - [MSGL_DBG2] = "debug", + [MSGL_DEBUG] = "debug", }; static int script_log(lua_State *L) diff --git a/sub/ass_mp.c b/sub/ass_mp.c index e77ce298dd..83d56e4fc6 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -209,8 +209,8 @@ static int map_ass_level[] = { MSGL_V, MSGL_V, MSGL_V, // 5 application recommended level - MSGL_DBG2, - MSGL_DBG3, // 7 "verbose DEBUG" + MSGL_DEBUG, + MSGL_TRACE, // 7 "verbose DEBUG" }; static void message_callback(int level, const char *format, va_list va, void *ctx) diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 881cd62835..87089cc9d0 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -549,7 +549,7 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), if (has_legacy) mp_msg_log(log, MSGL_V, "OpenGL legacy compat. found.\n"); - mp_msg_log(log, MSGL_DBG2, "Combined OpenGL extensions string:\n%s\n", + mp_msg_log(log, MSGL_DEBUG, "Combined OpenGL extensions string:\n%s\n", gl->extensions); for (int n = 0; n < sizeof(gl_functions) / sizeof(gl_functions[0]); n++) { diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 2e662f65ff..324013aef6 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -691,7 +691,7 @@ static GLuint create_shader(struct gl_video *p, GLenum type, const char *header, GLint log_length; gl->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); - int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DBG2) : MSGL_ERR; + int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DEBUG) : MSGL_ERR; const char *typestr = type == GL_VERTEX_SHADER ? "vertex" : "fragment"; if (mp_msg_test_log(p->log, pri)) { MP_MSG(p, pri, "%s shader source:\n", typestr); @@ -727,7 +727,7 @@ static void link_shader(struct gl_video *p, GLuint program) GLint log_length; gl->GetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length); - int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DBG2) : MSGL_ERR; + int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DEBUG) : MSGL_ERR; if (mp_msg_test_log(p->log, pri)) { GLchar *logstr = talloc_zero_size(NULL, log_length + 1); gl->GetProgramInfoLog(program, log_length, NULL, logstr);