原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://ticktick.blog.51cto.com/823160/1867059
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
/**
* Send the specified message to the log if the level is less than or equal
* to the current av_log_level. By default, all logging messages are sent to
* stderr. This behavior can be altered by setting a different logging callback
* function.
* @see av_log_set_callback
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message expressed using a @ref
* lavu_log_constants "Logging Constant".
* @param fmt The format string (printf-compatible) that specifies how
* subsequent arguments are converted to output.
*/
void
av_log(
void
*avcl,
int
level,
const
char
*fmt, …);
|
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
|
/**
* Print no output.
*/
#define AV_LOG_QUIET -8
/**
* Something went really wrong and we will crash now.
*/
#define AV_LOG_PANIC 0
/**
* Something went wrong and recovery is not possible.
* For example, no header was found for a format which depends
* on headers or an illegal combination of parameters is used.
*/
#define AV_LOG_FATAL 8
/**
* Something went wrong and cannot losslessly be recovered.
* However, not all future data is affected.
*/
#define AV_LOG_ERROR 16
/**
* Something somehow does not look correct. This may or may not
* lead to problems. An example would be the use of '-vstrict -2'.
*/
#define AV_LOG_WARNING 24
/**
* Standard information.
*/
#define AV_LOG_INFO 32
/**
* Detailed information.
*/
#define AV_LOG_VERBOSE 40
/**
* Stuff which is only useful for libav* developers.
*/
#define AV_LOG_DEBUG 48
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/**
* Get the current log level
*
* @see lavu_log_constants
*
* @return Current log level
*/
int
av_log_get_level(
void
);
/**
* Set the log level
*
* @see lavu_log_constants
*
* @param level Logging level
*/
void
av_log_set_level(
int
level);
|
1
2
|
av_log(NULL, AV_LOG_DEBUG,
"Hello World ! \n"
);
av_log(NULL, AV_LOG_ERROR,
"Error:%d ! \n"
, errorCode);
|
1
2
3
4
5
6
7
8
9
10
11
12
|
#ifndef _SYS_LOG_
#define _SYS_LOG_
#include <libavutil/log.h>
#define LOGD(format, ...) av_log(NULL, AV_LOG_DEBUG, format, ##__VA_ARGS__);
#define LOGV(format, ...) av_log(NULL, AV_LOG_VERBOSE, format, ##__VA_ARGS__);
#define LOGI(format, ...) av_log(NULL, AV_LOG_INFO, format, ##__VA_ARGS__);
#define LOGW(format, ...) av_log(NULL, AV_LOG_WARNING, format, ##__VA_ARGS__);
#define LOGE(format, ...) av_log(NULL, AV_LOG_ERROR, format, ##__VA_ARGS__);
#endif
|
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
|
#ifdef __ANDROID_API__
#include <android/log.h>
#define ALOG(level, TAG, ...) ((void)__android_log_vprint(level, TAG, __VA_ARGS__))
#define SYS_LOG_TAG "nmplayer"
static
void
syslog_print(
void
*ptr,
int
level,
const
char
*fmt,
va_list
vl)
{
switch
(level) {
case
AV_LOG_DEBUG:
ALOG(ANDROID_LOG_VERBOSE, SYS_LOG_TAG, fmt, vl);
break
;
case
AV_LOG_VERBOSE:
ALOG(ANDROID_LOG_DEBUG, SYS_LOG_TAG, fmt, vl);
break
;
case
AV_LOG_INFO:
ALOG(ANDROID_LOG_INFO, SYS_LOG_TAG, fmt, vl);
break
;
case
AV_LOG_WARNING:
ALOG(ANDROID_LOG_WARN, SYS_LOG_TAG, fmt, vl);
break
;
case
AV_LOG_ERROR:
ALOG(ANDROID_LOG_ERROR, SYS_LOG_TAG, fmt, vl);
break
;
}
}
static
void
syslog_init()
{
av_log_set_callback(syslog_print);
}
#endif // __ANDROID_API__
|
1
|
$ ffplay -v debug $URL
|
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
|
-loglevel [repeat+]loglevel | -v [repeat+]loglevel
Set the logging level used by the library. Adding
"repeat+"
indicates that repeated
log
output should not be compressed to the first line and the
"Last message repeated n times"
line will be omitted.
"repeat"
can also be used alone. If
"repeat"
is used alone, and with no prior loglevel set, the
default
loglevel will be used. If multiple loglevel parameters are given,
using
’repeat’ will not change the loglevel. loglevel is a string or a number containing one of the following values:
‘quiet, -8’
Show nothing at all; be silent.
‘panic, 0’
Only show fatal errors which could lead the process to crash, such as an assertion failure. This is not currently used
for
anything.
‘fatal, 8’
Only show fatal errors. These are errors after which the process absolutely cannot
continue
.
‘error, 16’
Show all errors, including ones which can be recovered from.
‘warning, 24’
Show all warnings and errors. Any message related to possibly incorrect or unexpected events will be shown.
‘info, 32’
Show informative messages during processing. This is in addition to warnings and errors. This is the
default
value.
‘verbose, 40’
Same as info, except more verbose.
‘debug, 48’
Show everything, including debugging information.
‘trace, 56’
By
default
the program logs to stderr. If coloring is supported by the terminal, colors are used to mark errors and warnings. Log coloring can be disabled setting the environment variable AV_LOG_FORCE_NOCOLOR or NO_COLOR, or can be forced setting the environment variable AV_LOG_FORCE_COLOR. The use of the environment variable NO_COLOR is
deprecated
and will be dropped in a future FFmpeg version.
|