45static void (*ni_log_callback)(int,
const char*, va_list) =
49static ni_pthread_mutex_t ni_log2_mutex;
50static int ni_log2_mutex_initialized = 0;
51INIT_ONCE g_InitOnce_ni_log2_mutex = INIT_ONCE_STATIC_INIT;
53static ni_pthread_mutex_t ni_log2_mutex = PTHREAD_MUTEX_INITIALIZER;
56static int ni_log2_print_with_mutex = 0;
58#define NI_LOG2_SESSION_ID_TIMESTAMP_FMT "[SID=%x, TS=" "%" PRIu64 "]"
59#define NI_LOG2_TIMESTAMP_FMT "[TS=" "%" PRIu64 "]"
60#define NI_LOG2_SESSION_ID_FMT "[SID=%x]"
61#define NI_LOG2_E2EID_FMT "|%s|"
62#define NI_LOG2_FMT_FMT "%s"
63#define NI_LOG2_SPACE " "
65#define NI_LOG2_PRINT_BUFF_SIZE 512
68#include <android/log.h>
70static char ni_log_tag[128] =
"libxcoder";
72#define ALOGV(fmt, ...) \
73 __android_log_vprint(ANDROID_LOG_VERBOSE, ni_log_tag, fmt, ##__VA_ARGS__)
74#define ALOGD(fmt, ...) \
75 __android_log_vprint(ANDROID_LOG_DEBUG, ni_log_tag, fmt, ##__VA_ARGS__)
76#define ALOGI(fmt, ...) \
77 __android_log_vprint(ANDROID_LOG_INFO, ni_log_tag, fmt, ##__VA_ARGS__)
78#define ALOGW(fmt, ...) \
79 __android_log_vprint(ANDROID_LOG_WARN, ni_log_tag, fmt, ##__VA_ARGS__)
80#define ALOGE(fmt, ...) \
81 __android_log_vprint(ANDROID_LOG_ERROR, ni_log_tag, fmt, ##__VA_ARGS__)
97 SYSTEMTIME system_time;
98 ULARGE_INTEGER ularge;
100 static const unsigned __int64 epoch =
101 ((
unsigned __int64)116444736000000000ULL);
107 GetSystemTime(&system_time);
108 SystemTimeToFileTime(&system_time, &file_time);
109 ularge.LowPart = file_time.dwLowDateTime;
110 ularge.HighPart = file_time.dwHighDateTime;
112 (void)ularge.LowPart;
113 (void)ularge.HighPart;
114 p_tp->tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L);
115 p_tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
119 return gettimeofday(p_tp, p_tzp);
136 if (level <= ni_log_level)
139#ifdef NI_LOG_TRACE_TIMESTAMPS
144 fprintf(stderr,
"[%" PRIu64
"] ", (uint64_t) (tv.tv_sec * 1000000LL + tv.tv_usec));
157 vfprintf(stderr, fmt, vl);
171 ni_log_callback = log_callback;
190 ni_log_callback(level, fmt, vl);
204 ni_log_level = level;
227 if (fflog_level <= -8)
231 else if (fflog_level <= 8)
235 else if (fflog_level <= 16)
239 else if (fflog_level <= 32)
243 else if (fflog_level <= 48)
251 return converted_ni_log_level;
265 int (*strcicmp) (
const char*,
const char *) = &_stricmp;
267 int (*strcicmp) (
const char*,
const char *) = &strcasecmp;
270 if (!(*strcicmp)(arg_str,
"none"))
273 }
else if (!(*strcicmp)(arg_str,
"fatal"))
276 }
else if (!(*strcicmp)(arg_str,
"error"))
279 }
else if (!(*strcicmp)(arg_str,
"info"))
282 }
else if (!(*strcicmp)(arg_str,
"debug"))
285 }
else if (!(*strcicmp)(arg_str,
"trace"))
301void ni_log_set_log_tag(
const char *log_tag)
303 strcpy(ni_log_tag, log_tag);
304 ni_log_tag[strlen(log_tag)] =
'\0';
312 return (uint64_t) (tv.tv_sec * 1000000LL + tv.tv_usec);
316static BOOL CALLBACK ni_log2_init_mutex_once_callback(PINIT_ONCE InitOnce,
321 ni_log2_mutex_initialized = 1;
329 if(!ni_log2_mutex_initialized && on)
331 InitOnceExecuteOnce(&g_InitOnce_ni_log2_mutex, ni_log2_init_mutex_once_callback, NULL, NULL);
334 ni_log2_print_with_mutex = on;
341 if(level > ni_log_level)
346 if(ni_log2_print_with_mutex)
355 else if(p_session_context)
370 ni_log_callback(level, fmt, vl);
384 ni_log_callback(level, fmt, vl);
394 int this_used_size = 0;
402 else if(p_session_context)
415 if(this_used_size < 0)
423 ni_log_callback(level, fmt, vl);
438 ni_log_callback(level, fmt, vl);
449 ni_log_callback(level, printbuf, vl);
Common NETINT definitions used by all modules.
Public definitions for operating NETINT video processing devices for video processing.
void ni_log_default_callback(int level, const char *fmt, va_list vl)
Default ni_log() callback.
ni_log_level_t ni_log_get_level(void)
Get ni_log_level.
#define NI_LOG2_SESSION_ID_FMT
#define NI_LOG2_TIMESTAMP_FMT
#define NI_LOG2_E2EID_FMT
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,
ni_log_level_t ff_to_ni_log_level(int fflog_level)
Convert ffmpeg log level integer to appropriate ni_log_level_t.
void ni_log_set_callback(void(*log_callback)(int, const char *, va_list))
Set ni_log() callback.
uint64_t ni_log_get_utime()
Get time for logs with microsecond timestamps.
ni_log_level_t arg_to_ni_log_level(const char *arg_str)
Convert terminal arg string to ni_log_level_t.
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
void ni_log2_with_mutex(int on)
set whether to use a lock or not in ni_log2
#define NI_LOG2_PRINT_BUFF_SIZE
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
int32_t ni_log_gettimeofday(struct timeval *p_tp, struct timezone *p_tzp)
Get time for logs with microsecond timestamps.
#define NI_LOG2_SESSION_ID_TIMESTAMP_FMT
int ni_pthread_mutex_lock(ni_pthread_mutex_t *mutex)
thread mutex lock
int ni_pthread_mutex_unlock(ni_pthread_mutex_t *mutex)
thread mutex unlock
int ni_pthread_mutex_init(ni_pthread_mutex_t *mutex)
initialize a mutex