libxcoder  5.2.0
ni_log.c File Reference

Logging definitions. More...

#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <inttypes.h>
#include <sys/time.h>
#include "ni_log.h"
#include "ni_defs.h"
#include "ni_device_api.h"
#include "ni_util.h"

Go to the source code of this file.

Macros

#define NI_LOG2_SESSION_ID_TIMESTAMP_FMT   "[SID=%x, TS=" "%" PRIu64 "]"
 
#define NI_LOG2_TIMESTAMP_FMT   "[TS=" "%" PRIu64 "]"
 
#define NI_LOG2_SESSION_ID_FMT   "[SID=%x]"
 
#define NI_LOG2_E2EID_FMT   "|%s|"
 
#define NI_LOG2_FMT_FMT   "%s"
 
#define NI_LOG2_SPACE   " "
 
#define NI_LOG2_PRINT_BUFF_SIZE   512
 

Functions

int32_t ni_log_gettimeofday (struct timeval *p_tp, struct timezone *p_tzp)
 Get time for logs with microsecond timestamps. More...
 
void ni_log_default_callback (int level, const char *fmt, va_list vl)
 Default ni_log() callback. More...
 
void ni_log_set_callback (void(*log_callback)(int, const char *, va_list))
 Set ni_log() callback. More...
 
void ni_log (ni_log_level_t level, const char *fmt,...)
 print log message using ni_log_callback More...
 
void ni_log_set_level (ni_log_level_t level)
 Set ni_log_level. More...
 
ni_log_level_t ni_log_get_level (void)
 Get ni_log_level. More...
 
ni_log_level_t ff_to_ni_log_level (int fflog_level)
 Convert ffmpeg log level integer to appropriate ni_log_level_t. More...
 
ni_log_level_t arg_to_ni_log_level (const char *arg_str)
 Convert terminal arg string to ni_log_level_t. More...
 
uint64_t ni_log_get_utime ()
 Get time for logs with microsecond timestamps. More...
 
void ni_log2_with_mutex (int on)
 set whether to use a lock or not in ni_log2 More...
 
void ni_log2 (const void *p_context, ni_log_level_t level, const char *fmt,...)
 print log message and additional information using ni_log_callback, More...
 

Detailed Description

Logging definitions.


Definition in file ni_log.c.

Macro Definition Documentation

◆ NI_LOG2_E2EID_FMT

#define NI_LOG2_E2EID_FMT   "|%s|"

Definition at line 61 of file ni_log.c.

◆ NI_LOG2_FMT_FMT

#define NI_LOG2_FMT_FMT   "%s"

Definition at line 62 of file ni_log.c.

◆ NI_LOG2_PRINT_BUFF_SIZE

#define NI_LOG2_PRINT_BUFF_SIZE   512

Definition at line 65 of file ni_log.c.

◆ NI_LOG2_SESSION_ID_FMT

#define NI_LOG2_SESSION_ID_FMT   "[SID=%x]"

Definition at line 60 of file ni_log.c.

◆ NI_LOG2_SESSION_ID_TIMESTAMP_FMT

#define NI_LOG2_SESSION_ID_TIMESTAMP_FMT   "[SID=%x, TS=" "%" PRIu64 "]"

Definition at line 58 of file ni_log.c.

◆ NI_LOG2_SPACE

#define NI_LOG2_SPACE   " "

Definition at line 63 of file ni_log.c.

◆ NI_LOG2_TIMESTAMP_FMT

#define NI_LOG2_TIMESTAMP_FMT   "[TS=" "%" PRIu64 "]"

Definition at line 59 of file ni_log.c.

Function Documentation

◆ arg_to_ni_log_level()

ni_log_level_t arg_to_ni_log_level ( const char *  arg_str)

Convert terminal arg string to ni_log_level_t.


Parameters
log_strcharacter pointer of log level arg in terminal
Returns
ni_log_level

Definition at line 262 of file ni_log.c.

◆ ff_to_ni_log_level()

ni_log_level_t ff_to_ni_log_level ( int  fflog_level)

Convert ffmpeg log level integer to appropriate ni_log_level_t.


Parameters
fflog_levelinteger representation of FFmpeg log level
Returns
ni_log_level

Definition at line 224 of file ni_log.c.

◆ ni_log()

void ni_log ( ni_log_level_t  level,
const char *  fmt,
  ... 
)

print log message using ni_log_callback


Parameters
[in]levellog level
[in]formatprintf format specifier
[in]...additional arguments
Returns

Definition at line 183 of file ni_log.c.

◆ ni_log2()

void ni_log2 ( const void *  p_context,
ni_log_level_t  level,
const char *  fmt,
  ... 
)

print log message and additional information using ni_log_callback,


Parameters
[in]p_contexta pointer to ni_session_context_t if p_context != NULL session_id/E2EID will be printed as extra information
[in]levellog level, if log_level == NI_LOG_ERROR timastamp will be printed as extra information
[in]formatprintf format specifier
[in]...additional arguments
Returns

Definition at line 337 of file ni_log.c.

◆ ni_log2_with_mutex()

void ni_log2_with_mutex ( int  on)

set whether to use a lock or not in ni_log2


Parameters
[in]onwhether to use a lock, 1-->use a lock, 0-->use extra buf(no lock)
Returns

Definition at line 326 of file ni_log.c.

◆ ni_log_default_callback()

void ni_log_default_callback ( int  level,
const char *  fmt,
va_list  vl 
)

Default ni_log() callback.


Parameters
[in]levellog level
[in]fmtprintf format specifier
[in]vlvariadric args list
Returns
Note
This function doesn't automatically append a newline to the end of the log message.

Definition at line 134 of file ni_log.c.

◆ ni_log_get_level()

ni_log_level_t ni_log_get_level ( void  )

Get ni_log_level.


Returns
ni_log_level

Definition at line 212 of file ni_log.c.

◆ ni_log_get_utime()

uint64_t ni_log_get_utime ( )

Get time for logs with microsecond timestamps.


Returns
microsecond timestamp

Definition at line 308 of file ni_log.c.

◆ ni_log_gettimeofday()

int32_t ni_log_gettimeofday ( struct timeval *  p_tp,
struct timezone *  p_tzp 
)

Get time for logs with microsecond timestamps.


Parameters
[in/out]p_tp timeval struct
[in]p_tzptimezone struct
Returns
return 0 for success, -1 for error

Definition at line 93 of file ni_log.c.

◆ ni_log_set_callback()

void ni_log_set_callback ( void(*)(int, const char *, va_list log_callback)

Set ni_log() callback.


Parameters
[in]callback
Returns

Definition at line 169 of file ni_log.c.

◆ ni_log_set_level()

void ni_log_set_level ( ni_log_level_t  level)

Set ni_log_level.


Parameters
levellog level
Returns

Definition at line 202 of file ni_log.c.