1 // Copyright 2024 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 #pragma once 15 16 #include <lib/async/dispatcher.h> 17 18 #include "pw_preprocessor/arguments.h" 19 #include "pw_preprocessor/compiler.h" 20 #include "pw_preprocessor/util.h" 21 22 PW_EXTERN_C_START 23 24 void pw_Log(int level, 25 const char* module_name, 26 unsigned int flags, 27 const char* file_name, 28 int line_number, 29 const char* message, 30 ...) PW_PRINTF_FORMAT(6, 7); 31 32 PW_EXTERN_C_END 33 34 #define PW_HANDLE_LOG(level, module, flags, message, ...) \ 35 pw_Log((level), \ 36 (module), \ 37 (flags), \ 38 __FILE__, \ 39 __LINE__, \ 40 message PW_COMMA_ARGS(__VA_ARGS__)) 41 42 // Use printf for logging. The first 2 bits of the PW_HANDLE_LOG "flags" int are 43 // reserved, so use the third bit. 44 #define PW_LOG_FLAG_USE_PRINTF 1 << 2 45 // When specified, the log message should not be logged. This is useful for 46 // disabling log levels at runtime. 47 #define PW_LOG_FLAG_IGNORE 1 << 3 48 49 namespace pw::log_fuchsia { 50 51 // Creates LogSink client and starts listening for interest changes on 52 // `dispatcher`. 53 void InitializeLogging(async_dispatcher_t* dispatcher); 54 55 } // namespace pw::log_fuchsia 56