Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lib / support / pw_log_chip / public / pw_log_chip / log_chip.h
1 /*
2  *    Copyright (c) 2020 Project CHIP Authors.
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 /**
18  *    @file
19  *        This header redirects Pigweed logging prints to chip.
20  */
21 #pragma once
22
23 #include <support/logging/CHIPLogging.h>
24
25 #include "pw_preprocessor/arguments.h"
26
27 /**
28  * Redirect pigweed log prints to chip logging.
29  * Currently does not use a log module, but this could be added when needed.
30  * pigweed debug and info level logs are mapped to chip's kLogCategory_Detail.
31  * All other log levels are mapped to chip's kLogCategory_Error.
32  *
33  * Note: This function should not be called directly, instead call the functions
34  *       in pw_log/log.h.
35  *
36  * @param[in] level    Pigweed log level.
37  * @param[in] flags    Pigweed logging flags, currently these are ignored.
38  * @param[in] message  The printf style log string.
39  */
40 #define PW_LOG(level, flags, message, ...)                                                                                         \
41     do                                                                                                                             \
42     {                                                                                                                              \
43         if (level >= PW_LOG_LEVEL_INFO)                                                                                            \
44         {                                                                                                                          \
45             ::chip::Logging::Log(::chip::Logging::kLogModule_NotSpecified,                                                         \
46                                  (level <= PW_LOG_LEVEL_INFO) ? ::chip::Logging::kLogCategory_Detail                               \
47                                                               : ::chip::Logging::kLogCategory_Error,                               \
48                                  message PW_COMMA_ARGS(__VA_ARGS__));                                                              \
49         }                                                                                                                          \
50     } while (0)