This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
forked from Stupeflix/sxplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.h
69 lines (54 loc) · 2.42 KB
/
log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* This file is part of sxplayer.
*
* Copyright (c) 2016 Stupeflix
*
* sxplayer 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.
*
* sxplayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with sxplayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LOG_H
#define LOG_H
#include <libavutil/log.h>
#include "sxplayer.h"
#ifndef ENABLE_DBG
# define ENABLE_DBG 0
#endif
#if ENABLE_DBG
# define LOG_LEVEL AV_LOG_DEBUG
#else
/* The following will affect the default usage (aka no user logging callback specified) */
# define LOG_LEVEL AV_LOG_ERROR // will log only errors
//# define LOG_LEVEL AV_LOG_WARNING // will log errors, warnings
//# define LOG_LEVEL AV_LOG_INFO // will log little information such as file opening and decoder in use
//# define LOG_LEVEL AV_LOG_DEBUG // will log most of the important actions (get/ret frame)
#endif
#define DO_LOG(c, log_level, ...) sxpi_log_print((c)->log_ctx, log_level, \
__FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG(c, level, ...) DO_LOG(c, SXPLAYER_LOG_##level, __VA_ARGS__)
#if ENABLE_DBG
#define TRACE(c, ...) do { DO_LOG(c, SXPLAYER_LOG_VERBOSE, __VA_ARGS__); fflush(stdout); } while (0)
#else
/* Note: this could be replaced by a "while(0)" but it wouldn't test the
* compilation of the printf format, so we use this more complex form. */
#define TRACE(c, ...) do { if (0) DO_LOG(c, SXPLAYER_LOG_VERBOSE, __VA_ARGS__); } while (0)
#endif
struct log_ctx;
struct log_ctx *sxpi_log_alloc(void);
int sxpi_log_init(struct log_ctx *ctx, void *avlog);
void sxpi_log_set_callback(struct log_ctx *ctx, void *arg,
sxplayer_log_callback_type callback);
void sxpi_log_print(void *log_ctx, int log_level, const char *filename,
int ln, const char *fn, const char *fmt, ...) av_printf_format(6, 7);
void sxpi_log_free(struct log_ctx **ctxp);
#endif /* LOG_H */