xref: /nrf52832-nimble/packages/NimBLE-latest/porting/nimble/include/modlog/modlog.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef H_MODLOG_
21 #define H_MODLOG_
22 
23 #include <stdint.h>
24 #include "log/log.h"
25 
26 extern void modlog_dummy(uint8_t level, const char *msg, ...);
27 
28 #define MODLOG_MODULE_DFLT 255
29 
30 #define MODLOG_LEVEL_ERROR    0
31 #define MODLOG_LEVEL_WARING   1
32 #define MODLOG_LEVEL_INFO     2
33 #define MODLOG_LEVEL_LOG      3
34 #define MODLOG_LEVEL_RAW      4
35 #define MODLOG_LEVEL_CRITICAL 5
36 
37 #define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \
38     modlog_dummy(MODLOG_LEVEL_LOG, (ml_msg_), ##__VA_ARGS__)
39 
40 #define MODLOG_INFO(ml_mod_, ml_msg_, ...) \
41     modlog_dummy(MODLOG_LEVEL_INFO, (ml_msg_), ##__VA_ARGS__)
42 
43 #define MODLOG_WARN(ml_mod_, ml_msg_, ...) \
44     modlog_dummy(MODLOG_LEVEL_WARING, (ml_msg_), ##__VA_ARGS__)
45 
46 #define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \
47     modlog_dummy(MODLOG_LEVEL_ERROR, (ml_msg_), ##__VA_ARGS__)
48 
49 #define MODLOG_RAW(ml_mod_, ml_msg_, ...) \
50     modlog_dummy(MODLOG_LEVEL_RAW, (ml_msg_), ##__VA_ARGS__)
51 
52 #define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \
53     modlog_dummy(MODLOG_LEVEL_CRITICAL, (ml_msg_), ##__VA_ARGS__)
54 
55 #define MODLOG(ml_lvl_, ml_mod_, ...) \
56     MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__)
57 
58 #define MODLOG_DFLT(ml_lvl_, ...) \
59     MODLOG(ml_lvl_, LOG_MODULE_DEFAULT, __VA_ARGS__)
60 
61 #endif
62