NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
modlog.h
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 <stdio.h>
24
25#include "../log_common/log_common.h"
26#include "../log/log.h"
27#include "../log_common/log_common.h"
28
29#ifdef ESP_PLATFORM
30#include "esp_log.h"
31#include <stdio.h>
32#include <stdarg.h>
33#endif
34
35#define MODLOG_MODULE_DFLT 255
36
37#ifdef ESP_PLATFORM
38#define MODLOG_ESP_LOCAL(level, ml_msg_, ...) do { \
39 if (MYNEWT_VAL(BLE_HS_LOG_LVL) <= LOG_LOCAL_LEVEL) ESP_LOG_LEVEL_LOCAL(level, "NimBLE", ml_msg_, ##__VA_ARGS__); \
40} while(0)
41
42#define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \
43 MODLOG_ESP_LOCAL(ESP_LOG_DEBUG, ml_msg_, ##__VA_ARGS__)
44
45#define MODLOG_INFO(ml_mod_, ml_msg_, ...) \
46 MODLOG_ESP_LOCAL(ESP_LOG_INFO, ml_msg_, ##__VA_ARGS__)
47
48#define MODLOG_WARN(ml_mod_, ml_msg_, ...) \
49 MODLOG_ESP_LOCAL(ESP_LOG_WARN, ml_msg_, ##__VA_ARGS__)
50
51#define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \
52 MODLOG_ESP_LOCAL(ESP_LOG_ERROR, ml_msg_, ##__VA_ARGS__)
53
54#define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \
55 MODLOG_ESP_LOCAL(ESP_LOG_ERROR, ml_msg_, ##__VA_ARGS__)
56
57#else
58
59#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__
60#define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \
61 printf((ml_msg_), ##__VA_ARGS__)
62#else
63#define MODLOG_DEBUG(ml_mod_, ...)
64#endif
65
66#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__
67#define MODLOG_INFO(ml_mod_, ml_msg_, ...) \
68 printf((ml_msg_), ##__VA_ARGS__)
69#else
70#define MODLOG_INFO(ml_mod_, ...)
71#endif
72
73#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__
74#define MODLOG_WARN(ml_mod_, ml_msg_, ...) \
75 printf((ml_msg_), ##__VA_ARGS__)
76#else
77#define MODLOG_WARN(ml_mod_, ...)
78#endif
79
80#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__
81#define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \
82 printf((ml_msg_), ##__VA_ARGS__)
83#else
84#define MODLOG_ERROR(ml_mod_, ...)
85#endif
86
87#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__
88#define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \
89 printf((ml_msg_), ##__VA_ARGS__)
90#else
91#define MODLOG_CRITICAL(ml_mod_, ...)
92#endif
93
94#endif
95
96#define MODLOG(ml_lvl_, ml_mod_, ...) \
97 MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__)
98
99#define MODLOG_DFLT(ml_lvl_, ...) \
100 MODLOG(ml_lvl_, LOG_MODULE_DEFAULT, __VA_ARGS__)
101
102#endif