Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_log / public / pw_log / options.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 // This file defines macros used to control the behavior of pw_log statements.
16 // Files that use pw_log may define these macros BEFORE any headers are
17 // #included to customize pw_log.
18 //
19 // For example, the following sets the log module name to "Foobar" and the
20 // minimum log level to WARN:
21 //
22 //   #define PW_LOG_MODULE_NAME "Foobar"
23 //   #define PW_LOG_LEVEL PW_LOG_LEVEL_WARN
24 //
25 //   #include "foo/bar.h"
26 //   #include "pw_log/log.h"
27 //
28 // Users of pw_log should not include this header directly; include
29 // "pw_log/log.h" instead. This header is separate from "pw_log/log.h" to avoid
30 // circular dependencies when implementing the pw_log facade.
31 #pragma once
32
33 // Default: Module name
34 //
35 // An empty string is used for the module name if it is not set. The
36 // PW_LOG_MODULE_NAME_DEFINED macro is set to 1 or 0 to allow pw_log backends to
37 // behave differently if the module name is defined. For example, a backend
38 // might prefix the format string with PW_LOG_MODULE_NAME ": ", but only if the
39 // module name is provided.
40 #ifdef PW_LOG_MODULE_NAME
41 #define PW_LOG_MODULE_NAME_DEFINED 1
42 #else
43 #define PW_LOG_MODULE_NAME ""
44 #define PW_LOG_MODULE_NAME_DEFINED 0
45 #endif  // PW_LOG_MODULE_NAME
46
47 // Default: Flags
48 //
49 // For log statements like LOG_INFO that don't have an explicit argument, this
50 // is used for the flags value.
51 #ifndef PW_LOG_DEFAULT_FLAGS
52 #define PW_LOG_DEFAULT_FLAGS 0
53 #endif  // PW_LOG_DEFAULT_FLAGS
54
55 // Default: Log level filtering
56 //
57 // All log statements have a level, and this define is the default filtering.
58 // This is compile-time filtering if the level is a constant.
59 #ifndef PW_LOG_LEVEL
60 #define PW_LOG_LEVEL PW_LOG_LEVEL_DEBUG
61 #endif  // PW_LOG_LEVEL
62
63 // Default: Log enabled expression
64 //
65 // This expression determines whether or not the statement is enabled and
66 // should be passed to the backend.
67 #ifndef PW_LOG_ENABLE_IF
68 #define PW_LOG_ENABLE_IF(level, flags) ((level) >= PW_LOG_LEVEL)
69 #endif  // PW_LOG_ENABLE_IF