53 #if HAVE_SETCONSOLETEXTATTRIBUTE
76 static int16_t background, attr_orig;
78 #define set_color(x) SetConsoleTextAttribute(con, background | color[x])
79 #define set_256color set_color
80 #define reset_color() SetConsoleTextAttribute(con, attr_orig)
104 #define set_color(x) fprintf(stderr, "\033[%d;3%dm", (color[x] >> 4) & 15, color[x] & 15)
105 #define set_256color(x) fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm", (color[x] >> 16) & 0xff, (color[x] >> 8) & 0xff)
106 #define reset_color() fprintf(stderr, "\033[0m")
113 #if HAVE_SETCONSOLETEXTATTRIBUTE
114 CONSOLE_SCREEN_BUFFER_INFO con_info;
115 con = GetStdHandle(STD_ERROR_HANDLE);
117 !getenv(
"AV_LOG_FORCE_NOCOLOR");
119 GetConsoleScreenBufferInfo(con, &con_info);
120 attr_orig = con_info.wAttributes;
121 background = attr_orig & 0xF0;
124 use_color = !getenv(
"NO_COLOR") && !getenv(
"AV_LOG_FORCE_NOCOLOR") &&
125 (getenv(
"TERM") && isatty(2) ||
126 getenv(
"AV_LOG_FORCE_COLOR"));
127 if (getenv(
"AV_LOG_FORCE_256COLOR"))
130 use_color = getenv(
"AV_LOG_FORCE_COLOR") && !getenv(
"NO_COLOR") &&
131 !getenv(
"AV_LOG_FORCE_NOCOLOR");
147 return (*(
AVClass **) ptr)->class_name;
152 return (*(
AVClass **) ptr)->category;
157 if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
167 || avc->
version < (51 << 16 | 59 << 8)
185 if (*print_prefix && avc) {
189 if (parent && *parent) {
191 (*parent)->item_name(parent), parent);
202 if(*part[0].str || *part[1].str || *part[2].str) {
203 char lastc = part[2].len ? part[2].str[part[2].len - 1] : 0;
204 *print_prefix = lastc ==
'\n' || lastc ==
'\r';
209 char *
line,
int line_size,
int *print_prefix)
212 format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
213 snprintf(line, line_size,
"%s%s%s", part[0].str, part[1].str, part[2].str);
219 static int print_prefix = 1;
233 format_line(ptr, level, fmt, vl, part, &print_prefix, type);
234 snprintf(line,
sizeof(line),
"%s%s%s", part[0].str, part[1].str, part[2].str);
238 is_atty = isatty(2) ? 1 : -1;
242 *line && line[strlen(line) - 1] !=
'\r'){
245 fprintf(stderr,
" Last message repeated %d times\r", count);
249 fprintf(stderr,
" Last message repeated %d times\n", count);
274 if (avc && avc->
version >= (50 << 16 | 15 << 8 | 2) &&
285 log_callback(avcl, level, fmt, vl);
309 va_list argument_list)
313 "version to the newest one from Git. If the problem still "
314 "occurs, it means that your file has a feature which has not "
315 "been implemented.\n");
318 "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
319 "and contact the ffmpeg-devel mailing list.\n");
324 va_list argument_list;
326 va_start(argument_list, msg);
328 va_end(argument_list);
333 va_list argument_list;
335 va_start(argument_list, msg);
337 va_end(argument_list);
void void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)
#define AV_LOG_WARNING
Something somehow does not look correct.
void av_log_set_level(int level)
Set the log level.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
const char * av_default_item_name(void *ctx)
Return the context name.
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.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
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.
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_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...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
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_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
common internal API header
Buffer to print data progressively.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
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
static void colored_fputs(int level, const char *str)
#define AV_LOG_INFO
Standard information.
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
typedef void(RENAME(mix_any_func_type))
static void format_line(void *ptr, int level, const char *fmt, va_list vl, AVBPrint part[3], int *print_prefix, int type[2])
Describe the class of an AVClass context structure.
void 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...
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int version
LIBAVUTIL_VERSION with which this structure was created.
int parent_log_context_offset
Offset in the structure where a pointer to the parent context for logging is stored.
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
Append a formatted string to a print buffer.
AVClassCategory av_default_get_category(void *ptr)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
void av_log_set_flags(int arg)
#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
common internal and external API header