1 // Copyright 2023 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 // pw_log backends that use pw_tokenizer and want to support nested tokenization 17 // define this file under their public_overrides/ directory to activate the 18 // PW_LOG_TOKEN aliases. If this file does not exist in the log backend, 19 // arguments behave as basic strings (const char*). 20 #if __has_include("pw_log_backend/log_backend_uses_pw_tokenizer.h") 21 22 #include "pw_tokenizer/nested_tokenization.h" 23 #include "pw_tokenizer/tokenize.h" 24 25 #define PW_LOG_TOKEN_TYPE pw_tokenizer_Token 26 #define PW_LOG_TOKEN PW_TOKENIZE_STRING 27 #define PW_LOG_TOKEN_EXPR PW_TOKENIZE_STRING_EXPR 28 #define PW_LOG_TOKEN_FMT PW_TOKEN_FMT 29 30 #else 31 32 /// If nested tokenization is supported by the logging backend, this is an 33 /// alias for `pw_tokenizer_Token`. 34 /// 35 /// For non-tokenizing backends, defaults to `const char*`. 36 #define PW_LOG_TOKEN_TYPE const char* 37 38 /// If nested tokenization is supported by the logging backend, this is an 39 /// alias for `PW_TOKENIZE_STRING`. No-op otherwise. 40 #define PW_LOG_TOKEN(string_literal) string_literal 41 42 /// If nested tokenization is supported by the logging backend, this is an 43 /// alias for `PW_TOKENIZE_STRING_EXPR`. No-op otherwise. 44 #define PW_LOG_TOKEN_EXPR(string_literal) string_literal 45 46 /// If nested tokenization is supported by the logging backend, this is an 47 /// alias for `PW_TOKEN_FORMAT`. 48 /// 49 /// For non-tokenizing backends, defaults to the string specifier `%s`. 50 #define PW_LOG_TOKEN_FMT() "%s" 51 52 #endif //__has_include("log_backend/log_backend_uses_pw_tokenizer.h") 53