libxcoder  3.5.1
ni_log_logan.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Copyright (C) 2022 NETINT Technologies
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18  * SOFTWARE.
19  *
20  ******************************************************************************/
21 
22 /*!*****************************************************************************
23 * \file ni_log_logan.h
24 *
25 * \brief Exported logging routines definition
26 *
27 *******************************************************************************/
28 
29 #pragma once
30 
31 #include <string.h>
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <time.h>
35 #ifdef LIBXCODER_OBJS_BUILD
36 #include "../build/xcoder_auto_headers.h"
37 #endif
38 
39 #ifdef _WIN32
40  #ifdef XCODER_DLL
41  #ifdef LIB_EXPORTS
42  #define LIB_API_LOG __declspec(dllexport)
43  #else
44  #define LIB_API_LOG __declspec(dllimport)
45  #endif
46  #else
47  #define LIB_API_LOG
48  #endif
49 #elif defined(__linux__) || defined(__APPLE__)
50  #define LIB_API_LOG
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #ifndef QUADRA
58 
59 typedef enum
60 {
67  NI_LOG_TRACE = 5
69 
70 /*!*************************************/
71 // libxcoder logging utility
72 /*!******************************************************************************
73  * \brief Default ni_log() callback
74  *
75  * \param[in] level log level
76  * \param[in] fmt printf format specifier
77  * \param[in] vl variadric args list
78  *
79  * \return
80  *******************************************************************************/
81 LIB_API_LOG void ni_log_default_callback(int level, const char* fmt, va_list vl);
82 
83 /*!******************************************************************************
84  * \brief Set ni_log() callback
85  *
86  * \param[in] callback
87  *
88  * \return
89  *******************************************************************************/
90 LIB_API_LOG void ni_log_set_callback(void (*log_callback)(int, const char*, va_list));
91 
92 /*!******************************************************************************
93  * \brief print log message using ni_log_callback
94  *
95  * \param[in] level log level
96  * \param[in] format printf format specifier
97  * \param[in] ... additional arguments
98  *
99  * \return
100  *******************************************************************************/
101 LIB_API_LOG void ni_log(ni_log_level_t level, const char *fmt, ...);
102 
103 /*!******************************************************************************
104  * \brief Set ni_log_level
105  *
106  * \param level log level
107  *
108  * \return
109  *******************************************************************************/
110 LIB_API_LOG void ni_log_set_level(ni_log_level_t level);
111 
112 /*!******************************************************************************
113  * \brief Get ni_log_level
114  *
115  * \return ni_log_level
116  *******************************************************************************/
117 LIB_API_LOG ni_log_level_t ni_log_get_level(void);
118 
119 /*!******************************************************************************
120  * \brief Convert ffmpeg log level integer to appropriate ni_log_level_t
121  *
122  * \param fflog_level integer representation of FFmpeg log level
123  *
124  * \return ni_log_level
125  *******************************************************************************/
126 LIB_API_LOG ni_log_level_t ff_to_ni_log_level(int fflog_level);
127 
128 #ifdef __ANDROID__
129 /*!******************************************************************************
130  * \brief Set ni_log_tag
131  *
132  * \param log tag
133  *
134  * \return
135  *******************************************************************************/
136 LIB_API_LOG void ni_log_set_log_tag(const char *log_tag);
137 #endif
138 
139 #endif // #ifndef QUADRA
140 
141 #ifdef __cplusplus
142 }
143 #endif
ni_log_level_t
Definition: ni_log_logan.h:60
@ NI_LOG_NONE
Definition: ni_log_logan.h:62
@ NI_LOG_DEBUG
Definition: ni_log_logan.h:66
@ NI_LOG_TRACE
Definition: ni_log_logan.h:67
@ NI_LOG_FATAL
Definition: ni_log_logan.h:63
@ NI_LOG_ERROR
Definition: ni_log_logan.h:64
@ NI_LOG_INFO
Definition: ni_log_logan.h:65
@ NI_LOG_INVALID
Definition: ni_log_logan.h:61
LIB_API_LOG void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
Definition: ni_log_logan.c:138
LIB_API_LOG void ni_log_set_callback(void(*log_callback)(int, const char *, va_list))
Set ni_log() callback.
Definition: ni_log_logan.c:106
LIB_API_LOG ni_log_level_t ff_to_ni_log_level(int fflog_level)
Convert ffmpeg log level integer to appropriate ni_log_level_t.
Definition: ni_log_logan.c:160
LIB_API_LOG void ni_log_default_callback(int level, const char *fmt, va_list vl)
Default ni_log() callback.
Definition: ni_log_logan.c:71
LIB_API_LOG ni_log_level_t ni_log_get_level(void)
Get ni_log_level.
Definition: ni_log_logan.c:148
LIB_API_LOG void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
Definition: ni_log_logan.c:120