45 #if HAVE_SETCONSOLETEXTATTRIBUTE
68 static int16_t background, attr_orig;
70 #define set_color(x) SetConsoleTextAttribute(con, background | color[x])
71 #define set_256color set_color
72 #define reset_color() SetConsoleTextAttribute(con, attr_orig)
96 #define set_color(x) fprintf(stderr, "\033[%d;3%dm", (color[x] >> 4) & 15, color[x] & 15)
97 #define set_256color(x) fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm", (color[x] >> 16) & 0xff, (color[x] >> 8) & 0xff)
98 #define reset_color() fprintf(stderr, "\033[0m")
105 #if HAVE_SETCONSOLETEXTATTRIBUTE
106 CONSOLE_SCREEN_BUFFER_INFO con_info;
107 con = GetStdHandle(STD_ERROR_HANDLE);
108 use_color = (con != INVALID_HANDLE_VALUE) && !getenv(
"NO_COLOR") &&
109 !getenv(
"AV_LOG_FORCE_NOCOLOR");
111 GetConsoleScreenBufferInfo(con, &con_info);
112 attr_orig = con_info.wAttributes;
113 background = attr_orig & 0xF0;
116 use_color = !getenv(
"NO_COLOR") && !getenv(
"AV_LOG_FORCE_NOCOLOR") &&
117 (getenv(
"TERM") && isatty(2) ||
118 getenv(
"AV_LOG_FORCE_COLOR"));
119 if (getenv(
"AV_LOG_FORCE_256COLOR"))
122 use_color = getenv(
"AV_LOG_FORCE_COLOR") && !getenv(
"NO_COLOR") &&
123 !getenv(
"AV_LOG_FORCE_NOCOLOR");
139 return (*(
AVClass **) ptr)->class_name;
144 return (*(
AVClass **) ptr)->category;
149 if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
159 || avc->
version < (51 << 16 | 59 << 8)
169 char part[3][
LINE_SZ],
int part_size,
int *print_prefix,
int type[2])
172 part[0][0] = part[1][0] = part[2][0] = 0;
174 if (*print_prefix && avc) {
178 if (parent && *parent) {
179 snprintf(part[0], part_size,
"[%s @ %p] ",
180 (*parent)->item_name(parent), parent);
184 snprintf(part[1], part_size,
"[%s @ %p] ",
191 *print_prefix = strlen(part[2]) && part[2][strlen(part[2]) - 1] ==
'\n';
195 char *
line,
int line_size,
int *print_prefix)
198 format_line(ptr, level, fmt, vl, part,
sizeof(part[0]), print_prefix,
NULL);
199 snprintf(line, line_size,
"%s%s%s", part[0], part[1], part[2]);
204 static int print_prefix = 1;
214 format_line(ptr, level, fmt, vl, part,
sizeof(part[0]), &print_prefix, type);
215 snprintf(line,
sizeof(line),
"%s%s%s", part[0], part[1], part[2]);
219 is_atty = isatty(2) ? 1 : -1;
225 fprintf(stderr,
" Last message repeated %d times\r", count);
229 fprintf(stderr,
" Last message repeated %d times\n", count);
249 if (avc && avc->
version >= (50 << 16 | 15 << 8 | 2) &&