FFmpeg
Loading...
Searching...
No Matches
log.c File Reference

logging functions More...

#include "config.h"
#include <inttypes.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bprint.h"
#include "common.h"
#include "internal.h"
#include "log.h"
#include "thread.h"
#include "time.h"
#include "time_internal.h"

Go to the source code of this file.

Macros

#define LINE_SZ   1024
 
#define NB_LEVELS   8
 

Functions

static void check_color_terminal (void)
 
static void ansi_fputs (int level, int tint, const char *str, int local_use_color)
 
static void colored_fputs (int level, int tint, const char *str)
 
const char * av_default_item_name (void *ptr)
 Return the context name.
 
AVClassCategory av_default_get_category (void *ptr)
 
static void sanitize (uint8_t *line)
 
static int get_category (void *ptr)
 
static const char * get_level_str (int level)
 
static const char * item_name (void *obj, const AVClass *cls)
 
static void format_date_now (AVBPrint *bp_time, int include_date)
 
static void format_line (void *avcl, int level, const char *fmt, va_list vl, AVBPrint part[5], int *print_prefix, int type[2])
 
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.
 
int av_log_format_line2 (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.
 
void av_log_default_callback (void *ptr, int level, const char *fmt, va_list vl)
 Default logging callback.
 
void av_log (void *avcl, int level, const char *fmt,...)
 
void av_log_once (void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
 
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 av_log_get_level (void)
 Get the current log level.
 
void av_log_set_level (int level)
 Set the log level.
 
void av_log_set_flags (int arg)
 
int av_log_get_flags (void)
 
void av_log_set_callback (void(*callback)(void *, int, const char *, va_list))
 Set the logging callback.
 
static void missing_feature_sample (int sample, void *avc, const char *msg, va_list argument_list)
 
void avpriv_request_sample (void *avc, const char *msg,...)
 
void avpriv_report_missing_feature (void *avc, const char *msg,...)
 

Variables

static AVMutex mutex = AV_MUTEX_INITIALIZER
 
static atomic_int av_log_level = AV_LOG_INFO
 
static atomic_int av_log_flags = 0
 
static const uint32_t color [16+AV_CLASS_CATEGORY_NB]
 
static int use_color = -1
 
static atomic_uintptr_t av_log_callback = (uintptr_t)av_log_default_callback
 

Detailed Description

logging functions

Definition in file log.c.

Macro Definition Documentation

◆ LINE_SZ

#define LINE_SZ   1024

Definition at line 51 of file log.c.

Referenced by av_log_default_callback().

◆ NB_LEVELS

#define NB_LEVELS   8

Definition at line 62 of file log.c.

Function Documentation

◆ check_color_terminal()

static void check_color_terminal ( void )
static

Definition at line 154 of file log.c.

Referenced by colored_fputs().

◆ ansi_fputs()

static void ansi_fputs ( int level,
int tint,
const char * str,
int local_use_color )
static

Definition at line 189 of file log.c.

Referenced by colored_fputs().

◆ colored_fputs()

static void colored_fputs ( int level,
int tint,
const char * str )
static

Definition at line 213 of file log.c.

Referenced by av_log_default_callback().

◆ sanitize()

static void sanitize ( uint8_t * line)
static

Definition at line 251 of file log.c.

Referenced by av_log_default_callback().

◆ get_category()

static int get_category ( void * ptr)
static

Definition at line 259 of file log.c.

Referenced by format_line().

◆ get_level_str()

static const char * get_level_str ( int level)
static

Definition at line 272 of file log.c.

Referenced by format_line().

◆ item_name()

static const char * item_name ( void * obj,
const AVClass * cls )
static

Definition at line 298 of file log.c.

◆ format_date_now()

static void format_date_now ( AVBPrint * bp_time,
int include_date )
static

Definition at line 303 of file log.c.

Referenced by format_line().

◆ format_line()

static void format_line ( void * avcl,
int level,
const char * fmt,
va_list vl,
AVBPrint part[5],
int * print_prefix,
int type[2] )
static

Definition at line 320 of file log.c.

Referenced by av_log_default_callback(), and av_log_format_line2().

◆ av_log()

void av_log ( void * avcl,
int level,
const char * fmt,
... )

Definition at line 442 of file log.c.

◆ av_log_once()

void av_log_once ( void * avcl,
int initial_level,
int subsequent_level,
int * state,
const char * fmt,
... )

◆ missing_feature_sample()

static void missing_feature_sample ( int sample,
void * avc,
const char * msg,
va_list argument_list )
static

Definition at line 496 of file log.c.

Referenced by avpriv_report_missing_feature(), and avpriv_request_sample().

◆ avpriv_request_sample()

void avpriv_request_sample ( void * avc,
const char * msg,
... )

Definition at line 510 of file log.c.

◆ avpriv_report_missing_feature()

void avpriv_report_missing_feature ( void * avc,
const char * msg,
... )

Definition at line 519 of file log.c.

Variable Documentation

◆ mutex

AVMutex mutex = AV_MUTEX_INITIALIZER
static

Definition at line 49 of file log.c.

◆ av_log_level

atomic_int av_log_level = AV_LOG_INFO
static

Definition at line 59 of file log.c.

Referenced by av_log_default_callback(), av_log_get_level(), av_log_set_level(), and cb_log().

◆ av_log_flags

atomic_int av_log_flags = 0
static

Definition at line 60 of file log.c.

Referenced by av_log_default_callback(), av_log_get_flags(), av_log_set_flags(), and format_line().

◆ color

const uint32_t color[16+AV_CLASS_CATEGORY_NB]
static
Initial value:
= {
[AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
[AV_LOG_FATAL /8] = 208 << 8 | 0x41,
[AV_LOG_ERROR /8] = 196 << 8 | 0x11,
[AV_LOG_WARNING/8] = 226 << 8 | 0x03,
[AV_LOG_INFO /8] = 253 << 8 | 0x09,
[AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
[AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
[AV_LOG_TRACE /8] = 34 << 8 | 0x07,
[16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
[16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
[16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
[16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
[16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
[16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
[16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
[16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
[16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
[16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
[16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
[16+AV_CLASS_CATEGORY_HWDEVICE ] = 214 << 8 | 0x13,
[16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15,
[16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05,
[16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15,
[16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05,
[16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15,
[16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05,
}
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
Definition log.h:197
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition log.h:204
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AV_CLASS_CATEGORY_INPUT
Definition log.h:30
@ AV_CLASS_CATEGORY_MUXER
Definition log.h:32
@ AV_CLASS_CATEGORY_SWSCALER
Definition log.h:38
@ AV_CLASS_CATEGORY_BITSTREAM_FILTER
Definition log.h:37
@ AV_CLASS_CATEGORY_DEVICE_OUTPUT
Definition log.h:45
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
Definition log.h:43
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
Definition log.h:41
@ AV_CLASS_CATEGORY_NA
Definition log.h:29
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
Definition log.h:42
@ AV_CLASS_CATEGORY_FILTER
Definition log.h:36
@ AV_CLASS_CATEGORY_DEMUXER
Definition log.h:33
@ AV_CLASS_CATEGORY_OUTPUT
Definition log.h:31
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT
Definition log.h:44
@ AV_CLASS_CATEGORY_DEVICE_INPUT
Definition log.h:46
@ AV_CLASS_CATEGORY_SWRESAMPLER
Definition log.h:39
@ AV_CLASS_CATEGORY_ENCODER
Definition log.h:34
@ AV_CLASS_CATEGORY_DECODER
Definition log.h:35
@ AV_CLASS_CATEGORY_HWDEVICE
Definition log.h:40

Definition at line 98 of file log.c.

◆ use_color

int use_color = -1
static

Definition at line 127 of file log.c.

Referenced by ansi_fputs(), check_color_terminal(), checkasm_vfprintf(), colored_fputs(), and main().

◆ av_log_callback

atomic_uintptr_t av_log_callback = (uintptr_t)av_log_default_callback
static

Definition at line 440 of file log.c.

Referenced by av_log_set_callback(), and av_vlog().