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.
|
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...
|
|
Logging definitions.
Definition in file ni_log.c.
◆ NI_LOG2_E2EID_FMT
#define NI_LOG2_E2EID_FMT "|%s|" |
◆ NI_LOG2_FMT_FMT
#define NI_LOG2_FMT_FMT "%s" |
◆ NI_LOG2_PRINT_BUFF_SIZE
#define NI_LOG2_PRINT_BUFF_SIZE 512 |
◆ NI_LOG2_SESSION_ID_FMT
#define NI_LOG2_SESSION_ID_FMT "[SID=%x]" |
◆ NI_LOG2_SESSION_ID_TIMESTAMP_FMT
#define NI_LOG2_SESSION_ID_TIMESTAMP_FMT "[SID=%x, TS=" "%" PRIu64 "]" |
◆ NI_LOG2_SPACE
#define NI_LOG2_SPACE " " |
◆ NI_LOG2_TIMESTAMP_FMT
#define NI_LOG2_TIMESTAMP_FMT "[TS=" "%" PRIu64 "]" |
◆ arg_to_ni_log_level()
Convert terminal arg string to ni_log_level_t.
- Parameters
-
log_str | character 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()
Convert ffmpeg log level integer to appropriate ni_log_level_t.
- Parameters
-
fflog_level | integer representation of FFmpeg log level |
- Returns
- ni_log_level
Definition at line 224 of file ni_log.c.
◆ ni_log()
print log message using ni_log_callback
- Parameters
-
[in] | level | log level |
[in] | format | printf 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_context | a pointer to ni_session_context_t if p_context != NULL session_id/E2EID will be printed as extra information |
[in] | level | log level, if log_level == NI_LOG_ERROR timastamp will be printed as extra information |
[in] | format | printf 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] | on | whether 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] | level | log level |
[in] | fmt | printf format specifier |
[in] | vl | variadric 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()
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_tzp | timezone 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 | ) |
|
◆ ni_log_set_level()
Set ni_log_level.
- Parameters
-
- Returns
Definition at line 202 of file ni_log.c.