1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: Radisys Logging Framework
23 Desc: This file contains logging framework include file.
25 *********************************************************************21*/
26 ///////////////////////////////////////////////////////////////////////////////
27 // @ description: This is header file is used by applications who want to
28 // define LOG Macros. This file can be refered for integrating log library
29 // into any application. API's defined in the file should be used by the
30 // program to modify data at runtime.
31 ///////////////////////////////////////////////////////////////////////////////
33 #ifndef __RL_INTERFACE_H__
35 #include "rl_common.h"
37 ///////////////////////////////////////////////////////////////////////////////
38 // This API is used to set logging directory path. If set after the log
39 // initialization API, next file creation will happen in this directory
40 void rlSetLogPath(const char* logDir);
42 ///////////////////////////////////////////////////////////////////////////////
43 // This API needs to be called after configuring all the required parameters
44 // by using below APIs. This API initializes logging framework.
45 // Log MACRO's should be used only after calling this API.
46 void rlInitLog(U8 type);
48 ///////////////////////////////////////////////////////////////////////////////
49 // This initializes log file name. Log file name should be exclusive of
50 // extension. As framework appends ".bin" in case of binary file and ".txt" in
51 // case of plain text logging. If file name is "stdout" and TEXT logging is
52 // enabled, logs will be printed in console. Run time file name can be changed
53 // and will be applicable when next file is created.
54 void rlSetLogFile(const char* fileName);
56 ///////////////////////////////////////////////////////////////////////////////
57 // This API is used to set remote logging port, where post-processor application
58 // (rlogapp) is used to connect on this port in order to receive live binary logs.
59 // This API can be used only during initialization time.
60 void rlSetLogPort(U32 port);
62 ///////////////////////////////////////////////////////////////////////////////
63 // Use this API to set log level. This API supports run time modification of
65 void rlSetLogLevel(R_LOG_LEVEL logLevel);
67 ///////////////////////////////////////////////////////////////////////////////
68 // This API toggles the module mask. If logging for this module is already
69 // enabled, it will be disabled. If it's not enabled, it will enable. Zero
70 // input will disable logging mask for all modules.
71 void rlSetModuleMask(U32 modMask);
73 ///////////////////////////////////////////////////////////////////////////////
74 // This API is used to set log file size limit for single file.
75 void rlSetLogFileSizeLimit(U32 maxFileSize);
77 ///////////////////////////////////////////////////////////////////////////////
78 // This API sets the limit of number of log files that can be created by
80 void rlSetNumOfLogFiles(U8 nMaxFiles);
82 ///////////////////////////////////////////////////////////////////////////////
83 // This API is used to set circular buffer size for each thread. Based on the
84 // number of threads in the system this size needs to be chosen. Recommended
85 // minimum 100Kb buffer size.
86 void rlSetCircularBufferSize(U32 bufSize);
88 ///////////////////////////////////////////////////////////////////////////////
89 // This API enables or disables remote logging application connection to see
91 void rlSetRemoteLoggingFlag(S32 flag);
93 ///////////////////////////////////////////////////////////////////////////////
94 // To change or modify logging level using console, console input needs to be
95 // passed to this function.
96 int rlHandleConInput(char ch);
98 ///////////////////////////////////////////////////////////////////////////////
99 // This API enables or disables core file generation based on the input flag
100 // value. 1 Enables core dump and 0 disables generating core dump.
101 void rlEnableDisableCore(S32 enable_core);
103 ///////////////////////////////////////////////////////////////////////////////
104 // This API enables Bufferd IO, to disable frequent file operation
105 void rlEnaBleBufferedIO(void);
107 ///////////////////////////////////////////////////////////////////////////////
108 // This API updates the RLOG Tti count baed on this time stamp will be updated
109 extern void rlUpdateRlogTti(void);
111 ///////////////////////////////////////////////////////////////////////////////
112 // This API reset the RLOG rate control count and enable logging every 10 ms
113 extern void rlResetLogRateLmt(void);
115 ///////////////////////////////////////////////////////////////////////////////
116 // This API reset the RLOG rate control count and enable logging every 10 ms
117 extern void rlResetLogRateLmt(void);
119 ///////////////////////////////////////////////////////////////////////////////
120 // This API Start the limit the number of logs loggd into circular buffer every
122 extern void rlStartLogCountLimit(void);
124 ///////////////////////////////////////////////////////////////////////////////
125 // This API stops restriciton of limiting number of logs every 10 ms
126 extern void rlStopLogCountLimit(void);
131 #include "rl_redirect.h"
135 #if defined(RLOG_ENABLE_TEXT_LOGGING)
137 #define FMTSTR "[%d-%d-%d %d:%d:%d.%03d][%s]%s:%d\n%s:"
138 #define FMTSTR_S "[%d-%d-%d %d:%d:%d.%03d][%s]%s:%d\n%s:%s:%ld:"
140 #define LOG_ARG0(_level, _fmtStr) \
141 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
143 logLev0(g_logStr[_level],RLOG_MODULE_NAME, __FILE__,__LINE__, FMTSTR _fmtStr "\n\n", RLOG_FILE_ID); \
146 #define LOG_ARGN(_N, _level, _fmtStr, ...) \
147 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
149 logLev##_N(g_logStr[_level],RLOG_MODULE_NAME, __FILE__,__LINE__, FMTSTR _fmtStr "\n\n", ##__VA_ARGS__ , RLOG_FILE_ID); \
152 #define LOG_SPL(_level, _splenum, _splArg, _fmtStr, ...) \
153 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
155 logLevE(g_logStr[_level],RLOG_MODULE_NAME, __FILE__,__LINE__, FMTSTR_S _fmtStr "\n\n", _splenum,_splArg, ##__VA_ARGS__, RLOG_FILE_ID); \
158 #define LOG_ARGX(_level, _fmtStr, ...) \
159 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
161 logLevN(_level,RLOG_MODULE_NAME, __FILE__,__LINE__, _fmtStr "\n\n", __VA_ARGS__, RLOG_FILE_ID); \
164 #define RLOG0(_level, _lstr) LOG_ARG0(_level, _lstr)
165 #define RLOG1(_level, _lstr, _arg1) LOG_ARGN(1, _level, _lstr, _arg1)
166 #define RLOG2(_level, _lstr, _arg1, _arg2) LOG_ARGN(2, _level, _lstr, _arg1, _arg2)
167 #define RLOG3(_level, _lstr, _arg1, _arg2, _arg3) LOG_ARGN(3, _level, _lstr, _arg1, _arg2, _arg3)
168 #define RLOG4(_level, _lstr, _arg1, _arg2, _arg3, _arg4)LOG_ARGN(4, _level, _lstr, _arg1, _arg2, _arg3, _arg4)
170 #else /* BINARY LOGGING */
172 #define LOG_ARG0(_level, _fmtStr) \
173 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
175 logLev0(_LOGID, _level, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \
178 #define LOG_ARGN(_N, _level, _fmtStr, ...) \
179 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
181 logLev##_N(_LOGID, _level, ##__VA_ARGS__, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \
184 #define LOG_SPL(_level, _splenum, _splArg, _fmtStr, ...) \
185 if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\
187 logLevE(_LOGID,_level,_splenum, _splArg, ##__VA_ARGS__, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \
190 #define RLOG0(_level, _lstr) LOG_ARG0(_level, _lstr)
191 #define RLOG1(_level, _lstr, _arg1) LOG_ARGN(1, _level, _lstr, _arg1)
192 #define RLOG2(_level, _lstr, _arg1, _arg2) LOG_ARGN(2, _level, _lstr, _arg1, _arg2)
193 #define RLOG3(_level, _lstr, _arg1, _arg2, _arg3) LOG_ARGN(3, _level, _lstr, _arg1, _arg2, _arg3)
194 #define RLOG4(_level, _lstr, _arg1, _arg2, _arg3, _arg4)LOG_ARGN(4, _level, _lstr, _arg1, _arg2, _arg3, _arg4)
196 #endif /* if defined(RLOG_ENABLE_TEXT_LOGGING) */
198 #define RLOG_STR(_level, _lstr, _strarg) LOG_ARGN(S, _level, _lstr, _strarg)
199 #define RLOG_HEX(_level, _lstr, _hexdata, _hexlen) LOG_ARGN(H, _level, _lstr, _hexdata, _hexlen)
201 #define RLOG_ARG0(_level, _splenum, _splArg, _lstr) \
202 LOG_SPL(_level, _splenum, _splArg, _lstr, 0, 0, 0, 0)
204 #define RLOG_ARG1(_level, _splenum, _splArg, _lstr, _arg1) \
205 LOG_SPL(_level, _splenum, _splArg, _lstr, _arg1, 0, 0, 0)
207 #define RLOG_ARG2(_level, _splenum, _splArg, _lstr, _arg1, _arg2) \
208 LOG_SPL(_level, _splenum, _splArg, _lstr, _arg1, _arg2, 0, 0)
210 #define RLOG_ARG3(_level, _splenum, _splArg, _lstr, _arg1, _arg2, _arg3) \
211 LOG_SPL(_level, _splenum, _splArg, _lstr, _arg1, _arg2, _arg3, 0)
213 #define RLOG_ARG4(_level, _splenum, _splArg, _lstr, _arg1, _arg2, _arg3, _arg4) \
214 LOG_SPL(_level, _splenum, _splArg, _lstr, _arg1, _arg2, _arg3, _arg4)
216 #endif /* WR_DBG_CIRLOG */
217 #endif /* __RLOG_INTERFACE_H__*/