Learn more: Tokenized log arguments
Namespaces | |
| namespace | pw |
| The Pigweed namespace. | |
Macros | |
| #define | PW_STATUS_DOMAIN "::pw::Status" |
Tokenizer domain for pw_Status and pw::Status codes. | |
| #define | PW_STATUS_CODE_FMT PW_LOG_TOKEN_FMT(PW_STATUS_DOMAIN) |
| #define | PW_STATUS_FMT PW_LOG_STATUS_DOMAIN_FMT(PW_STATUS_DOMAIN, 5) |
| #define | PW_LOG_STATUS_DOMAIN_FMT(domain, code_bits) PW_LOG_TOKEN_FMT(domain) |
| #define | PW_LOG_STATUS(...) PW_LOG_ENUM(::pw::log::internal::LoggedStatus(__VA_ARGS__)) |
| #define | PW_LOG_ENUM_FMT(enum) PW_LOG_TOKEN_FMT(#enum) |
| #define | PW_LOG_TOKEN_TYPE const char* |
| #define | PW_LOG_TOKEN_DEFAULT_VALUE nullptr |
| #define | PW_LOG_TOKEN(...) PW_DELEGATE_BY_ARG_COUNT(_PW_STRING_OPTIONAL_DOMAIN_, __VA_ARGS__) |
| #define | PW_LOG_TOKEN_EXPR(...) PW_DELEGATE_BY_ARG_COUNT(_PW_STRING_OPTIONAL_DOMAIN_, __VA_ARGS__) |
| #define | PW_LOG_TOKEN_FMT(...) "%s" |
| #define | PW_LOG_ENUM(...) ::pw::EnumToString(::pw::log::internal::ToEnum(__VA_ARGS__)) |
| #define | PW_LOG_NESTED_TOKEN_FMT(...) "%s::%s" |
| #define | PW_LOG_ENUM_VERSIONED_FMT(...) "%s" |
| #define | PW_LOG_ENUM_VERSIONED(...) PW_LOG_ENUM(__VA_ARGS__) |
| #define PW_LOG_ENUM | ( | ... | ) | ::pw::EnumToString(::pw::log::internal::ToEnum(__VA_ARGS__)) |
Converts an enum to the log argument for a static-domain format specifier (such as a generated <ENUM>_FMT macro). Evaluates its argument once.
If nested tokenization is supported by the logging backend, returns the 32-bit enum token. For non-tokenizing backends, returns the string name of the enumerator (const char*).
With pw_log/status.h included, also accepts statuses with enum codes, pw::StatusWithSize, and pw::Result, and logs their status code.
| #define PW_LOG_ENUM_FMT | ( | enum | ) | PW_LOG_TOKEN_FMT(#enum) |
Format specifier for logging a PW_TOKENIZE_ENUM enum with PW_LOG_ENUM.
If nested tokenization is supported by the logging backend, this expands to a nested token format specifier using #enum as the domain. For non-tokenizing backends, defaults to s.
pw_enum types use versioned tokenizer domains. Log them with the generated <ENUM>_FMT macro or PW_LOG_ENUM_VERSIONED_FMT() instead. | #define PW_LOG_ENUM_VERSIONED | ( | ... | ) | PW_LOG_ENUM(__VA_ARGS__) |
Converts an enum to the arguments needed to log its enumerator with PW_LOG_ENUM_VERSIONED_FMT(). Accepts the same types as PW_LOG_ENUM and evaluates its argument once.
If nested tokenization is supported by the logging backend, expands to two arguments: the 32-bit versioned domain token and the enum value token. For non-tokenizing backends, expands to the enumerator string (const char*).
| #define PW_LOG_ENUM_VERSIONED_FMT | ( | ... | ) | "%s" |
Type-agnostic format specifier for logging a versioned enum or status code with PW_LOG_ENUM_VERSIONED.
On both tokenizing and non-tokenizing backends, formats as the enumerator string (for example, "SECOND" or "NOT_FOUND").
| #define PW_LOG_NESTED_TOKEN_FMT | ( | ... | ) | "%s::%s" |
If nested tokenization is supported by the logging backend, this is an alias for PW_NESTED_TOKEN_FMT.
For non-tokenizing backends, defaults to s::s.
| #define PW_LOG_STATUS | ( | ... | ) | PW_LOG_ENUM(::pw::log::internal::LoggedStatus(__VA_ARGS__)) |
Expands to the argument needed to log a status and its optional message with <STATUS>_FMT or PW_STATUS_FMT. Accepts pw::Status, other statuses with enum codes, pw::StatusWithSize, and pw::Result. Evaluates its argument once.
The status logs as CODE, or as CODE (message) if it has a message:
With a non-tokenizing pw_log backend and status messages enabled, the argument is a string in a temporary buffer that only exists until the end of the log statement.
| #define PW_LOG_STATUS_DOMAIN_FMT | ( | domain, | |
| code_bits | |||
| ) | PW_LOG_TOKEN_FMT(domain) |
Format specifier for logging a status with PW_LOG_STATUS. Generated pw_enum statuses define <STATUS>_FMT with this macro.
Formats as CODE, or as CODE (message) if the status has a message.
| [in] | domain | String literal with the tokenizer domain of the status's code enum. |
| [in] | code_bits | Number of low bits that the status's code occupies when it shares a 32-bit word with a message token: the bit width of the code enum (pw::EnumTraits<Code>::kBitWidth), or 32 if the code enum does not support messages. Must be a decimal integer literal. If it is wrong, tokenized logs of the status cannot be decoded. |
| #define PW_LOG_TOKEN | ( | ... | ) | PW_DELEGATE_BY_ARG_COUNT(_PW_STRING_OPTIONAL_DOMAIN_, __VA_ARGS__) |
If nested tokenization is supported by the logging backend, this is an alias for PW_TOKENIZE_STRING. No-op otherwise.
| #define PW_LOG_TOKEN_DEFAULT_VALUE nullptr |
An "empty" value for a token.
If nested tokenization is supported by the logging backend, this is 0. Otherwise, it is nullptr.
| #define PW_LOG_TOKEN_EXPR | ( | ... | ) | PW_DELEGATE_BY_ARG_COUNT(_PW_STRING_OPTIONAL_DOMAIN_, __VA_ARGS__) |
If nested tokenization is supported by the logging backend, this is an alias for PW_TOKENIZE_STRING_EXPR. No-op otherwise.
| #define PW_LOG_TOKEN_FMT | ( | ... | ) | "%s" |
If nested tokenization is supported by the logging backend, this is an alias for PW_TOKEN_FMT.
For non-tokenizing backends, defaults to the string specifier s.
| #define PW_LOG_TOKEN_TYPE const char* |
If nested tokenization is supported by the logging backend, this is an alias for pw_tokenizer_Token.
For non-tokenizing backends, defaults to const char*.
| #define PW_STATUS_CODE_FMT PW_LOG_TOKEN_FMT(PW_STATUS_DOMAIN) |
Format specifier for logging the code of a pw::Status, pw_Status, pw::StatusWithSize, or pw::Result<T> with PW_LOG_ENUM.
| #define PW_STATUS_FMT PW_LOG_STATUS_DOMAIN_FMT(PW_STATUS_DOMAIN, 5) |
Format specifier for logging a pw::Status, pw::StatusWithSize, or pw::Result<T> with PW_LOG_STATUS.
Describe what failed, then log the status: