50 #if HAVE_VALGRIND_VALGRIND_H
51 #include <valgrind/valgrind.h>
53 #define BACKTRACE_LOGLEVEL AV_LOG_ERROR
60 #if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
90 static int16_t background, attr_orig;
127 #if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
128 CONSOLE_SCREEN_BUFFER_INFO con_info;
129 con = GetStdHandle(STD_ERROR_HANDLE);
131 !getenv(
"AV_LOG_FORCE_NOCOLOR");
133 GetConsoleScreenBufferInfo(con, &con_info);
134 attr_orig = con_info.wAttributes;
135 background = attr_orig & 0xF0;
138 char *term = getenv(
"TERM");
139 use_color = !getenv(
"NO_COLOR") && !getenv(
"AV_LOG_FORCE_NOCOLOR") &&
140 (getenv(
"TERM") &&
isatty(2) || getenv(
"AV_LOG_FORCE_COLOR"));
141 if ( getenv(
"AV_LOG_FORCE_256COLOR")
142 || (term && strstr(term,
"256color")))
145 use_color = getenv(
"AV_LOG_FORCE_COLOR") && !getenv(
"NO_COLOR") &&
146 !getenv(
"AV_LOG_FORCE_NOCOLOR");
162 #if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
164 SetConsoleTextAttribute(con, background |
color[level]);
167 SetConsoleTextAttribute(con, attr_orig);
169 if (local_use_color == 1) {
171 "\033[%d;3%dm%s\033[0m",
172 (
color[level] >> 4) & 15,
177 "\033[48;5;%dm\033[38;5;%dm%s\033[0m",
178 (
color[level] >> 16) & 0xff,
181 }
else if (local_use_color == 256) {
183 "\033[48;5;%dm\033[38;5;%dm%s\033[0m",
184 (
color[level] >> 16) & 0xff,
185 (
color[level] >> 8) & 0xff,
195 return (*(
AVClass **) ptr)->class_name;
200 return (*(
AVClass **) ptr)->category;
205 if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
215 || avc->
version < (51 << 16 | 59 << 8)
249 AVBPrint part[4],
int *print_prefix,
int type[2])
258 if (*print_prefix && avc) {
262 if (parent && *parent) {
264 (*parent)->item_name(parent), parent);
278 if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
279 char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
280 *print_prefix = lastc ==
'\n' || lastc ==
'\r';
285 char *
line,
int line_size,
int *print_prefix)
289 snprintf(line, line_size,
"%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
295 static int print_prefix = 1;
305 tint = level & 0xff00;
315 format_line(ptr, level, fmt, vl, part, &print_prefix, type);
316 snprintf(line,
sizeof(line),
"%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
320 is_atty =
isatty(2) ? 1 : -1;
324 *line && line[strlen(line) - 1] !=
'\r'){
327 fprintf(stderr,
" Last message repeated %d times\r", count);
331 fprintf(stderr,
" Last message repeated %d times\n", count);
344 #if CONFIG_VALGRIND_BACKTRACE
345 if (level <= BACKTRACE_LOGLEVEL)
346 VALGRIND_PRINTF_BACKTRACE(
"");
363 if (avc && avc->
version >= (50 << 16 | 15 << 8 | 2) &&
374 log_callback(avcl, level, fmt, vl);
403 va_list argument_list)
407 "version to the newest one from Git. If the problem still "
408 "occurs, it means that your file has a feature which has not "
409 "been implemented.\n");
412 "of this file to ftp://upload.ffmpeg.org/incoming/ "
413 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
418 va_list argument_list;
420 va_start(argument_list, msg);
422 va_end(argument_list);
427 va_list argument_list;
429 va_start(argument_list, msg);
431 va_end(argument_list);
438 int main(
int argc,
char **argv)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
static const char * get_level_str(int level)
#define AV_LOG_WARNING
Something somehow does not look correct.
void av_log_set_level(int level)
Set the log level.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define AV_LOG_QUIET
Print no output.
static void missing_feature_sample(int sample, void *avc, const char *msg, va_list argument_list)
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
int log_level_offset_offset
Offset in the structure where log_level_offset is stored.
static void sanitize(uint8_t *line)
#define AV_LOG_VERBOSE
Detailed information.
static int get_category(void *ptr)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
static void format_line(void *avcl, int level, const char *fmt, va_list vl, AVBPrint part[4], int *print_prefix, int type[2])
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
void av_log(void *avcl, int level, const char *fmt,...)
int av_log_get_level(void)
Get the current log level.
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
common internal API header
static void check_color_terminal(void)
void avpriv_report_missing_feature(void *avc, const char *msg,...)
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType devtype)
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static void(* av_log_callback)(void *, int, const char *, va_list)
AVClassCategory(* get_category)(void *ctx)
Callback to return the category.
static pthread_mutex_t * mutex
const char *(* item_name)(void *ctx)
A pointer to a function which returns the name of a context instance ctx associated with the class...
#define AV_LOG_INFO
Standard information.
int av_log_get_flags(void)
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
Describe the class of an AVClass context structure.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int version
LIBAVUTIL_VERSION with which this structure was created.
common internal and external API header
int parent_log_context_offset
Offset in the structure where a pointer to the parent context for logging is stored.
AVClassCategory av_default_get_category(void *ptr)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
void avpriv_request_sample(void *avc, const char *msg,...)
void av_log_set_flags(int arg)
#define AV_LOG_PRINT_LEVEL
Include the log severity in messages originating from codecs.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
#define INVALID_HANDLE_VALUE
int main(int argc, char **argv)
static void colored_fputs(int level, int tint, const char *str)