xref: /aosp_15_r20/external/pigweed/pw_log/public/pw_log/options.h (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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 #include "pw_log/config.h"
34 
35 // These configuration options differ from the options in pw_log/config.h in
36 // that these should be set at a module/compile unit level rather than a global
37 // level level.
38 
39 // Default: Module name
40 //
41 // An empty string is used for the module name if it is not set.
42 #ifndef PW_LOG_MODULE_NAME
43 #define PW_LOG_MODULE_NAME ""
44 #endif  // PW_LOG_MODULE_NAME
45 
46 // Default: Log level filtering
47 //
48 // All log statements have a level, and this define sets the log level to the
49 // globally set default if PW_LOG_LEVEL was not already set by the module.
50 // This is compile-time filtering if the level is a constant.
51 #ifndef PW_LOG_LEVEL
52 #define PW_LOG_LEVEL PW_LOG_LEVEL_DEFAULT
53 #endif  // PW_LOG_LEVEL
54 
55 // Default: Flags
56 //
57 // For log statements like LOG_INFO that don't have an explicit argument, this
58 // is used for the flags value.
59 #ifndef PW_LOG_FLAGS
60 #define PW_LOG_FLAGS PW_LOG_FLAGS_DEFAULT
61 #endif  // PW_LOG_FLAGS
62 
63 // DEPRECATED: Use PW_LOG_FLAGS.
64 // TODO: b/234876701 - Remove this macro after migration.
65 #ifndef PW_LOG_DEFAULT_FLAGS
66 #define PW_LOG_DEFAULT_FLAGS PW_LOG_FLAGS
67 #endif  // PW_LOG_DEFAULT_FLAGS
68