AM243x MCU+ SDK  09.00.00
ub_logging.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
70 #ifndef UB_LOGGING_H_
71 #define UB_LOGGING_H_
72 
84 typedef enum {
94 
95 
96 #ifndef MAX_LOGMSG_CATEGORIES
97 
98 #define MAX_LOGMSG_CATEGORIES 16
99 #endif
100 
104 #define DBGMSG_LEVEL_MARK {"NON", "FTL", "ERR", "WRN", "INF", "IFV", "DBG", "DBV"}
105 
110 #define UBL_TS_BIT_FIELDS 3 // bit0 and bit1
111 
116 #define UBL_OVERRIDE_ISTR(x,y) ub_log_initstr_override(x,UBB_GETENV(y))
117 
118 #ifdef PRINT_FORMAT_NO_WARNING
119 
120 #define PRINT_FORMAT_ATTRIBUTE1
121 #define PRINT_FORMAT_ATTRIBUTE4
122 #else
123 
124 #define PRINT_FORMAT_ATTRIBUTE1 __attribute__((format (printf, 1, 2)))
125 #define PRINT_FORMAT_ATTRIBUTE4 __attribute__((format (printf, 4, 5)))
126 #endif
127 
134 void ub_console_debug_select_print(bool console, bool debug, const char *astr);
135 
146 const char *ub_log_initstr_override(const char *ns, const char *os);
147 
155 void ub_log_init(const char *istr);
156 
165 int ub_log_add_category(const char *catstr);
166 
176 int ub_log_print(int cat_index, int flags, ub_dbgmsg_level_t level, const char *astr);
177 
182 bool ub_clog_on(int cat_index, ub_dbgmsg_level_t level);
183 
188 bool ub_dlog_on(int cat_index, ub_dbgmsg_level_t level);
189 
194 int ub_log_change(int cat_index, ub_dbgmsg_level_t clevel, ub_dbgmsg_level_t dlevel);
195 
200 int ub_log_return(int cat_index);
201 
206 void ub_log_flush(void);
207 
208 #endif
209 
UBL_WARN
@ UBL_WARN
Definition: ub_logging.h:88
UBL_NONE
@ UBL_NONE
Definition: ub_logging.h:85
ub_log_return
int ub_log_return(int cat_index)
return console log level and console log level to the previous status
ub_log_initstr_override
const char * ub_log_initstr_override(const char *ns, const char *os)
override 'istr' of ub_log_inig
UBL_INFO
@ UBL_INFO
Definition: ub_logging.h:89
ub_log_add_category
int ub_log_add_category(const char *catstr)
add a category of logging at the bottom of the index
ub_log_print
int ub_log_print(int cat_index, int flags, ub_dbgmsg_level_t level, const char *astr)
print log message
UBL_ERROR
@ UBL_ERROR
Definition: ub_logging.h:87
ub_log_flush
void ub_log_flush(void)
flush out messages on the both of cosole log and debug log
UBL_DEBUGV
@ UBL_DEBUGV
Definition: ub_logging.h:92
ub_clog_on
bool ub_clog_on(int cat_index, ub_dbgmsg_level_t level)
check if console log is enabled or not for the indicated cat_index and level
UBL_INFOV
@ UBL_INFOV
Definition: ub_logging.h:90
UBL_DEBUG
@ UBL_DEBUG
Definition: ub_logging.h:91
ub_dbgmsg_level_t
ub_dbgmsg_level_t
This defines different logging levels.
Definition: ub_logging.h:84
ub_log_init
void ub_log_init(const char *istr)
initialize logging by a string
flags
uint32_t flags
Definition: csl_udmap_tr.h:0
ub_log_change
int ub_log_change(int cat_index, ub_dbgmsg_level_t clevel, ub_dbgmsg_level_t dlevel)
change console log level to clevel, and debug log level to delevl
ub_dlog_on
bool ub_dlog_on(int cat_index, ub_dbgmsg_level_t level)
check if debug log is enabled or not for the indicated cat_index and level
UBL_FATAL
@ UBL_FATAL
Definition: ub_logging.h:86
ub_console_debug_select_print
void ub_console_debug_select_print(bool console, bool debug, const char *astr)
output to console out and debug out by selection