2010-01-31 00:24:23 +01:00
|
|
|
/*
|
2015-04-13 09:36:54 +02:00
|
|
|
* This file is part of mpv.
|
2010-01-31 00:24:23 +01:00
|
|
|
*
|
2017-05-05 06:53:23 +02:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-01-31 00:24:23 +01:00
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-31 00:24:23 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-05-05 06:53:23 +02:00
|
|
|
* GNU Lesser General Public License for more details.
|
2010-01-31 00:24:23 +01:00
|
|
|
*
|
2017-05-05 06:53:23 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-31 00:24:23 +01:00
|
|
|
*/
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#ifndef MPLAYER_MP_MSG_H
|
|
|
|
#define MPLAYER_MP_MSG_H
|
2002-02-23 16:12:55 +01:00
|
|
|
|
2009-07-25 06:24:39 +02:00
|
|
|
#include <stdarg.h>
|
2013-07-31 21:40:30 +02:00
|
|
|
#include <stdbool.h>
|
2013-12-18 17:12:21 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2014-08-29 12:09:04 +02:00
|
|
|
#include "osdep/compiler.h"
|
2013-07-31 21:40:30 +02:00
|
|
|
|
|
|
|
struct mp_log;
|
2009-07-25 06:24:39 +02:00
|
|
|
|
2013-12-18 19:04:30 +01:00
|
|
|
// A mp_log instance that never outputs anything.
|
|
|
|
extern struct mp_log *const mp_null_log;
|
2001-08-17 02:39:49 +02:00
|
|
|
|
2013-12-18 16:55:10 +01:00
|
|
|
// Verbosity levels.
|
2013-12-21 21:41:18 +01:00
|
|
|
enum {
|
2019-11-07 22:34:03 +01:00
|
|
|
MSGL_FATAL, // only errors (difference to MSGL_ERR isn't too clear)
|
|
|
|
MSGL_ERR, // only errors
|
|
|
|
MSGL_WARN, // only warnings
|
|
|
|
MSGL_INFO, // what you normally see on the terminal
|
|
|
|
MSGL_STATUS, // exclusively for the playback status line (-quiet disables)
|
|
|
|
MSGL_V, // -v | slightly more information than default
|
|
|
|
MSGL_DEBUG, // -v -v | full debug information; this and numerically below
|
|
|
|
// should not produce "per frame" output
|
|
|
|
MSGL_TRACE, // -v -v -v | anything that might flood the terminal
|
2014-04-17 21:47:00 +02:00
|
|
|
MSGL_STATS, // dumping fine grained stats (--dump-stats)
|
2014-01-16 21:34:47 +01:00
|
|
|
|
2014-04-24 18:44:46 +02:00
|
|
|
MSGL_MAX = MSGL_STATS,
|
2013-12-21 21:41:18 +01:00
|
|
|
};
|
2001-08-17 00:13:20 +02:00
|
|
|
|
2013-12-18 16:55:10 +01:00
|
|
|
struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
|
|
|
|
const char *name);
|
2004-08-24 21:36:17 +02:00
|
|
|
|
2013-12-21 21:49:13 +01:00
|
|
|
void mp_msg(struct mp_log *log, int lev, const char *format, ...)
|
2013-12-18 16:55:10 +01:00
|
|
|
PRINTF_ATTRIBUTE(3, 4);
|
2013-12-21 21:49:13 +01:00
|
|
|
void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va);
|
2001-08-17 00:13:20 +02:00
|
|
|
|
2018-11-10 12:53:33 +01:00
|
|
|
int mp_msg_level(struct mp_log *log);
|
|
|
|
|
|
|
|
static inline bool mp_msg_test(struct mp_log *log, int lev)
|
|
|
|
{
|
|
|
|
return lev <= mp_msg_level(log);
|
|
|
|
}
|
2013-12-21 21:40:45 +01:00
|
|
|
|
2020-05-10 16:40:26 +02:00
|
|
|
void mp_msg_set_max_level(struct mp_log *log, int lev);
|
|
|
|
|
2013-12-21 21:41:18 +01:00
|
|
|
// Convenience macros.
|
2013-12-21 21:49:13 +01:00
|
|
|
#define mp_fatal(log, ...) mp_msg(log, MSGL_FATAL, __VA_ARGS__)
|
|
|
|
#define mp_err(log, ...) mp_msg(log, MSGL_ERR, __VA_ARGS__)
|
|
|
|
#define mp_warn(log, ...) mp_msg(log, MSGL_WARN, __VA_ARGS__)
|
|
|
|
#define mp_info(log, ...) mp_msg(log, MSGL_INFO, __VA_ARGS__)
|
|
|
|
#define mp_verbose(log, ...) mp_msg(log, MSGL_V, __VA_ARGS__)
|
|
|
|
#define mp_dbg(log, ...) mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
|
|
|
|
#define mp_trace(log, ...) mp_msg(log, MSGL_TRACE, __VA_ARGS__)
|
2013-12-21 21:41:18 +01:00
|
|
|
|
2013-12-18 16:55:10 +01:00
|
|
|
// Convenience macros, typically called with a pointer to a context struct
|
2014-01-16 21:26:24 +01:00
|
|
|
// as first argument, which has a "struct mp_log *log;" member.
|
2013-12-18 16:55:10 +01:00
|
|
|
|
2013-12-21 21:49:13 +01:00
|
|
|
#define MP_MSG(obj, lev, ...) mp_msg((obj)->log, lev, __VA_ARGS__)
|
2013-12-18 16:55:10 +01:00
|
|
|
|
|
|
|
#define MP_FATAL(obj, ...) MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
|
|
|
|
#define MP_ERR(obj, ...) MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
|
|
|
|
#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__)
|
2013-12-21 21:41:18 +01:00
|
|
|
#define MP_DBG(obj, ...) MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
|
|
|
|
#define MP_TRACE(obj, ...) MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
|
2013-12-18 16:55:10 +01:00
|
|
|
|
2014-04-17 21:47:00 +02:00
|
|
|
// This is a bit special. See TOOLS/stats-conv.py what rules text passed
|
|
|
|
// to these functions should follow. Also see --dump-stats.
|
|
|
|
#define mp_stats(obj, ...) mp_msg(obj, MSGL_STATS, __VA_ARGS__)
|
|
|
|
#define MP_STATS(obj, ...) MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#endif /* MPLAYER_MP_MSG_H */
|