C/C++ API Reference
Loading...
Searching...
No Matches
log_tokenized.h
1// Copyright 2021 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 <stdint.h>
17
18#include "pw_log_tokenized/config.h"
19#include "pw_preprocessor/util.h"
20#include "pw_tokenizer/tokenize.h"
21
22// TODO(hepler): Remove these includes.
23#ifdef __cplusplus
24#include "pw_log_tokenized/metadata.h"
25#endif // __cplusplus
26
28
54#define PW_LOG_TOKENIZED_TO_GLOBAL_HANDLER_WITH_METADATA( \
55 level, module, flags, message, ...) \
56 do { \
57 _PW_TOKENIZER_CONST uintptr_t _pw_log_tokenized_module_token = \
58 PW_TOKENIZE_STRING_MASK("pw_log_module_names", \
59 ((1u << PW_LOG_TOKENIZED_MODULE_BITS) - 1u), \
60 module); \
61 const uintptr_t _pw_log_tokenized_level = level; \
62 PW_LOG_TOKENIZED_ENCODE_MESSAGE( \
63 (_PW_LOG_TOKENIZED_LEVEL(_pw_log_tokenized_level) | \
64 _PW_LOG_TOKENIZED_MODULE(_pw_log_tokenized_module_token) | \
65 _PW_LOG_TOKENIZED_FLAGS(flags) | _PW_LOG_TOKENIZED_LINE(__LINE__)), \
66 PW_LOG_TOKENIZED_FORMAT_STRING(module, message), \
67 __VA_ARGS__); \
68 } while (0)
69
71#define PW_LOG_TOKENIZED_TO_GLOBAL_HANDLER_WITH_PAYLOAD \
72 PW_LOG_TOKENIZED_TO_GLOBAL_HANDLER_WITH_METADATA
73
78#define PW_LOG_TOKENIZED_ENCODE_MESSAGE(metadata, format, ...) \
79 do { \
80 PW_TOKENIZE_FORMAT_STRING( \
81 PW_TOKENIZER_DEFAULT_DOMAIN, UINT32_MAX, format, __VA_ARGS__); \
82 _pw_log_tokenized_EncodeTokenizedLog(metadata, \
83 _pw_tokenizer_token, \
84 PW_TOKENIZER_ARG_TYPES(__VA_ARGS__) \
85 PW_COMMA_ARGS(__VA_ARGS__)); \
86 } while (0)
87
89PW_EXTERN_C_START
90
91void _pw_log_tokenized_EncodeTokenizedLog(uint32_t metadata,
93 pw_tokenizer_ArgTypes types,
94 ...);
95
96PW_EXTERN_C_END
uint32_t pw_tokenizer_Token
Definition: tokenize.h:41