1 // Copyright 2020 The Pigweed Authors
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
7 // https://www.apache.org/licenses/LICENSE-2.0
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
16 #include "pw_preprocessor/arguments.h"
17 #include "pw_preprocessor/compiler.h"
18 #include "pw_preprocessor/util.h"
22 // Log a message with the listed attributes.
23 void pw_Log(int level,
25 const char* module_name,
26 const char* file_name,
28 const char* function_name,
30 ...) PW_PRINTF_FORMAT(7, 8);
34 // Log a message with many attributes included.
36 // This is the log macro frontend that funnels everything into the C handler
37 // above, pw_Log(). It's not efficient at the callsite, since it passes many
38 // arguments. Additionally, the use of the __FUNC__ macro adds a static const
39 // char[] variable inside functions with a log.
41 // TODO(pwbug/87): Reconsider the naming of this module when more is in place.
42 #define PW_HANDLE_LOG(level, flags, message, ...) \
50 message PW_COMMA_ARGS(__VA_ARGS__)); \
55 #include <string_view>
57 namespace pw::log_basic {
59 // Sets the function to use to send log messages. Defaults to
60 // pw::sys_io::WriteLine.
61 void SetOutput(void (*log_output)(std::string_view log));
63 } // namespace pw::log_basic