rte_log.h(3)
π NAME π
rte_log.h β bestie, this is the logging header. You're reading page rte_log.h(3), straight out of the Library Functions Manual (section 3, the C library functions section, and yes she's iconic). β¨
πΈ SYNOPSIS πΈ
Okay so before literally anything else, you gotta pull in the whole girl squad of headers:
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <rte_common.h>
#include <rte_config.h>
π Macros π
These are the log type IDs and the log levels, and you will respect them:
#define RTE_LOGTYPE_EAL 0β the EAL log type, sitting at0. she's the OG.#define RTE_LOGTYPE_USER1 24#define RTE_LOGTYPE_USER2 25#define RTE_LOGTYPE_USER3 26#define RTE_LOGTYPE_USER4 27#define RTE_LOGTYPE_USER5 28#define RTE_LOGTYPE_USER6 29#define RTE_LOGTYPE_USER7 30#define RTE_LOGTYPE_USER8 31β the user log types1through8, numbered24all the way up to31. one through eight, no skipping π#define RTE_LOGTYPE_FIRST_EXT_ID 32β this one lives at32.#define RTE_LOG_EMERG 1Uβ emergency. the loudest one.#define RTE_LOG_ALERT 2Uβ alert.#define RTE_LOG_CRIT 3Uβ critical.#define RTE_LOG_ERR 4Uβ error.#define RTE_LOG_WARNING 5Uβ warning.#define RTE_LOG_NOTICE 6Uβ notice.#define RTE_LOG_INFO 7Uβ info.#define RTE_LOG_DEBUG 8Uβ debug, the chattiest.#define RTE_LOG_MAX RTE_LOG_DEBUGβ the max is literally justRTE_LOG_DEBUG. as she should be. periodt.#define RTE_LOG(l, t, ...)β macro, takesl,t, then whatever else.#define RTE_LOG_DP(l, t, ...)β same shape:l,t,....#define RTE_LOG_LINE(l, t, ...)βl,t,....#define RTE_LOG_DP_LINE(l, t, ...)βl,t,....#define RTE_LOG_LINE_PREFIX(l, t, prefix, args, ...)β now with aprefixand anargsin the middle, bestie.#define RTE_LOG_DP_LINE_PREFIX(l, t, prefix, args, ...)β same energy,l,t,prefix,args,....#define RTE_LOG_REGISTER(type, name, level)β registration macro, args:type,name,level.#define RTE_LOG_REGISTER_DEFAULT(type, level)β args:type,level.#define RTE_LOG_REGISTER_SUFFIX(type, suffix, level)β args:type,suffix,level.
π¦ Functions π¦
The whole function roster, no gatekeeping:
int rte_openlog_stream (FILE *f)FILE * rte_log_get_stream (void)void rte_log_set_global_level (uint32_t level)uint32_t rte_log_get_global_level (void)int rte_log_get_level (uint32_t logtype)bool rte_log_can_log (uint32_t logtype, uint32_t loglevel)int rte_log_set_level_pattern (const char *pattern, uint32_t level)int rte_log_set_level_regexp (const char *regex, uint32_t level)int rte_log_set_level (uint32_t logtype, uint32_t level)int rte_log_cur_msg_loglevel (void)int rte_log_cur_msg_logtype (void)int rte_log_register (const char *name)int rte_log_register_type_and_pick_level (const char *name, uint32_t level_def)void rte_log_list_types (FILE *out, const char *prefix)void rte_log_dump (FILE *f)
and then these two, which I am typing exactly as the page gives them, because bestie, look at them, and also I do not fix canon:
int rte_log (uint32_t level, uint32_t logtype, const char *format,...) __rte_cold __rte_format_printf(3
int int rte_vlog (uint32_t level, uint32_t logtype, const char *format, va_list ap) __rte_format_printf(3
π«Ά Not me being obsessed with the fact that it saysint intand the(3never closes. That's just how she's written down. Don't come for me, I copied it right.
π Detailed Description π
RTE Logs API π
This file provides a log API to RTE applications.
Definition in file rte_log.h.
β¨ Macro Definition Documentation β¨
Okay bestie, this is where the actual macro lore lives. Every single one, no skips. π«Ά
#define RTE_LOGTYPE_EAL 0
Log related to eal.
Definition at line 30 of file rte_log.h.
#define RTE_LOGTYPE_USER1 24
User-defined log type 1.
Definition at line 53 of file rte_log.h.
#define RTE_LOGTYPE_USER2 25
User-defined log type 2.
Definition at line 54 of file rte_log.h.
#define RTE_LOGTYPE_USER3 26
User-defined log type 3.
Definition at line 55 of file rte_log.h.
#define RTE_LOGTYPE_USER4 27
User-defined log type 4.
Definition at line 56 of file rte_log.h.
#define RTE_LOGTYPE_USER5 28
User-defined log type 5.
Definition at line 57 of file rte_log.h.
#define RTE_LOGTYPE_USER6 29
User-defined log type 6.
Definition at line 58 of file rte_log.h.
#define RTE_LOGTYPE_USER7 30
User-defined log type 7.
Definition at line 59 of file rte_log.h.
#define RTE_LOGTYPE_USER8 31
User-defined log type 8.
Definition at line 60 of file rte_log.h.
#define RTE_LOGTYPE_FIRST_EXT_ID 32
First identifier for extended logs
Definition at line 63 of file rte_log.h.
π The log levels, from "we are SO cooked" to "just chatting" π
These are the severity vibes. Lower number = more dire. <hotpink>1U</hotpink> is the end of the world, <mint>8U</mint> is you whispering into the void. πΈ
#define RTE_LOG_EMERG 1U
System is unusable.
Definition at line 66 of file rte_log.h.
#define RTE_LOG_ALERT 2U
Action must be taken immediately.
Definition at line 67 of file rte_log.h.
#define RTE_LOG_CRIT 3U
Critical conditions.
Definition at line 68 of file rte_log.h.
#define RTE_LOG_ERR 4U
Error conditions.
Definition at line 69 of file rte_log.h.
#define RTE_LOG_WARNING 5U
Warning conditions.
Definition at line 70 of file rte_log.h.
#define RTE_LOG_NOTICE 6U
Normal but significant condition.
Definition at line 71 of file rte_log.h.
#define RTE_LOG_INFO 7U
Informational.
Definition at line 72 of file rte_log.h.
#define RTE_LOG_DEBUG 8U
Debug-level messages.
Definition at line 73 of file rte_log.h.
#define RTE_LOG_MAX RTE_LOG_DEBUG
Most detailed log level.
Definition at line 74 of file rte_log.h.
π The logging macros themselves (the main characters, honestly) π
#define RTE_LOG( l, t, ...)
Value:
rte_log(RTE_LOG_ ## l, \
RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__)
Generates a log message.
The RTE_LOG() is a helper that prefixes the string with the log level and type, and call rte_log().
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value. (like, she needs the name, not a number, ok?)tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value....β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Returns
<mint>0</mint>: Success. π- Negative on error. π
Definition at line 332 of file rte_log.h.
#define RTE_LOG_DP( l, t, ...)
Value:
(void)((RTE_LOG_ ## l <= RTE_LOG_DP_LEVEL) ? \
rte_log(RTE_LOG_ ## l, \
RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \
0)
Generates a log message for data path.
Similar to RTE_LOG(), except that it is removed at compilation time if the RTE_LOG_DP_LEVEL configuration option is lower than the log level argument. (yes bestie, it literally vanishes. poof. gone. the compiler said "not today") β¨
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value.tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value....β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Returns
<mint>0</mint>: Success.- Negative on error.
Definition at line 356 of file rte_log.h.
#define RTE_LOG_LINE( l, t, ...)
Value:
do { \
RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \
RTE_LOG(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
RTE_FMT_TAIL(__VA_ARGS__ ,))); \
} while (0)
Generates a log message with a single trailing newline.
The RTE_LOG_LINE() is a helper that expands logging of a message with RTE_LOG() appending a single newline to the formatted message. ONE newline. not two. she's on her newline regulation arc. π
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value.tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value....β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Definition at line 386 of file rte_log.h.
#define RTE_LOG_DP_LINE( l, t, ...)
Value:
do { \
RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \
RTE_LOG_DP(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
RTE_FMT_TAIL(__VA_ARGS__ ,))); \
} while (0)
Generates a log message for data path with a single trailing newline.
Similar to RTE_LOG_LINE(), except that it is removed at compilation time if the RTE_LOG_DP_LEVEL configuration option is lower than the log level argument.
The RTE_LOG_LINE() is a helper that expands logging of a message with RTE_LOG_DP() appending a single newline to the formatted message.
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value.tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value....β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Definition at line 413 of file rte_log.h.
#define RTE_LOG_LINE_PREFIX( l, t, prefix, args, ...)
Value:
do { \
RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
} while (0)
Generates a log message with a supplied prefix and arguments with a single trailing newline.
The RTE_LOG_LINE_PREFIX() is a helper that expands logging of a message with RTE_LOG() prepending the supplied prefix and arguments appending a single newline to the formatted message. (prefix goes in FRONT bestie, we love a front-row seat) β¨
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value.tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value.prefixβ The prefix format string.argsβ The arguments for the prefix format string. Ifargscontains multiple arguments useRTE_LOG_COMMAto defer expansion. (iykyk β it's a macro-expansion timing thing)...β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Definition at line 444 of file rte_log.h.
#define RTE_LOG_DP_LINE_PREFIX( l, t, prefix, args, ...)
Value:
do { \
RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
} while (0)
Generates a log message for the data path with a supplied prefix and arguments with a single trailing newline.
The RTE_LOG_DP_LINE_PREFIX() is a helper that expands logging of a message with RTE_LOG_DP() prepending the supplied prefix and arguments appending a single newline to the formatted message.
Parameters
lβ Log level. A value betweenEMERG(1) andDEBUG(8). The short name is expanded by the macro, so it cannot be an integer value.tβ The log type, for example,EAL. The short name is expanded by the macro, so it cannot be an integer value.prefixβ The prefix format string.argsβ The arguments for the prefix format string. Ifargscontains multiple arguments useRTE_LOG_COMMAto defer expansion....β The fmt string, as inprintf(3), followed by the variable arguments required by the format.
Definition at line 473 of file rte_log.h.
πΈ Registering your own logtypes (glow-up era) π¦
#define RTE_LOG_REGISTER( type, name, level)
Value:
RTE_LOG_REGISTER_IMPL(type, RTE_STR(name), level)
Register a dynamic log type in constructor context with its name and level.
It is a wrapper macro for declaring the logtype, register the log and sets it's level in the constructor context. (one macro, three jobs, she's booked and busy) π
Parameters
typeβ The log type identifiernameβ Name for the log type to be registeredlevelβ Log level. A value betweenEMERG(1) andDEBUG(8).
Definition at line 501 of file rte_log.h.
#define RTE_LOG_REGISTER_DEFAULT( type, level)
Value:
RTE_LOG_REGISTER_IMPL(type, RTE_STR(RTE_LOG_DEFAULT_LOGTYPE), level)
This is an equivalent to RTE_LOG_REGISTER, but relying on the build system to select the right format for the logtype. (letting the build system pick the fit? iconic delegation honestly)
Definition at line 508 of file rte_log.h.
#define RTE_LOG_REGISTER_SUFFIX( type, suffix, level)
Value:
RTE_LOG_REGISTER_IMPL(type, \
RTE_STR(RTE_LOG_DEFAULT_LOGTYPE) "." RTE_STR(suffix), level)
This is an equivalent to RTE_LOG_REGISTER, but relying on the build system to select the right prefix for the logtype.
Definition at line 515 of file rte_log.h.
π FUNCTION DOCUMENTATION π
okay bestie, this is the part with all the actual functions β the little buttons you press to make logging do stuff. each one gets its own mini moment. let's go π¦
int rte_openlog_stream (FILE * f)
Swap out the stream the logging system writes to. π
you can do this whenever, literally any time, no bad vibes. that f argument is the stream where the logs go. and if f is NULL? bestie, it just falls back to the default output, which is stderr. iconic default behavior tbh.
Parameters
fβ pointer to the stream.
Returns
0on success. π- negative on error. π
FILE * rte_log_get_stream (void )
Grab the stream the logging system is currently using. (peep rte_openlog_stream() if you wanna change it instead β different function, different mood.)
Returns
- pointer to the stream. β¨
void rte_log_set_global_level (uint32_t level)
Set the global log level, the main character of log levels. π
after you call this, any log with a level lower or equal to the level you passed will actually show up. so like, it's a cutoff, and everything at or below it gets the green light.
Parameters
levelβ log level. a value betweenRTE_LOG_EMERG(1) andRTE_LOG_DEBUG(8).
uint32_t rte_log_get_global_level (void )
Read the current global log level. no cap, it's just a getter.
Returns
- the current global log level. π
int rte_log_get_level (uint32_t logtype)
Get the log level for one specific type.
Parameters
logtypeβ the log type identifier.
Returns
0on success, or a negative value iflogtypeis invalid. πβπ
bool rte_log_can_log (uint32_t logtype, uint32_t loglevel)
Vibe check for a single log: given a logtype, can a log at this loglevel actually get printed? π«Ά
Parameters
logtypeβ the log type identifierloglevelβ log level. a value betweenRTE_LOG_EMERG(1) andRTE_LOG_DEBUG(8).
Returns
- returns
'true'if the log can be printed and'false'if it can't. simple as that bestie.
int rte_log_set_level_pattern (const char * pattern, uint32_t level)
Set the log level for a type, but you find that type using a globbing pattern. fancy. πΈ
Parameters
patternβ the globbing pattern identifying the log type.levelβ the level to be set.
Returns
0on success, a negative value iflevelis invalid.
int rte_log_set_level_regexp (const char * regex, uint32_t level)
Same energy as above, except you're matching with a regular expression. iykyk. π
Parameters
regexβ the regular expression identifying the log type.levelβ the level to be set.
Returns
0on success, a negative value iflevelis invalid.
int rte_log_set_level (uint32_t logtype, uint32_t level)
Set the log level for a given type, the straightforward version.
Parameters
logtypeβ the log type identifier.levelβ the level to be set.
Returns
0on success, a negative value iflogtypeorlevelis invalid. π
int rte_log_cur_msg_loglevel (void )
Get the current loglevel of the message that's being processed right now. β
here's the tea: before the log subsystem calls your user-defined stream for logging, it sets a per-lcore variable holding the loglevel and the logtype of the message currently being processed. your user-defined log output function can get at that info through this function. slay.
Returns
- the loglevel of the message being processed. π
int rte_log_cur_msg_logtype (void )
Get the current logtype of the message being processed right now.
same lore as its sibling above π§ β before calling the user-defined stream for logging, the log subsystem sets a per-lcore variable with the loglevel and the logtype of the message being processed, and your user-defined log output function can reach that info via this function.
Returns
- the logtype of the message being processed. π
int rte_log_register (const char * name)
Register a dynamic log type. π
btw if a log is already registered with that same type, the returned value is the same as the previous one. no duplicates, no drama.
Parameters
nameβ the string identifying the log type.
Returns
>0: success, and the returned value is the log type identifier. π(-ENOMEM): cannot allocate memory. π
int rte_log_register_type_and_pick_level (const char * name, uint32_t level_def)
Register a dynamic log type and try to pick its level from the EAL options. two birds, one function. π¦
rte_log_register() gets called inside this one. if that works out, the function tries to search for a matching regexp in the list of EAL log level options and grabs the level from the last matching entry. and if literally nothing from the list applies? the level gets set to your user-defined default value. periodt.
Parameters
nameβ name for the log type to be registeredlevel_defβ fallback level to be set if the global list has no matching options
Returns
>=0: the newly registered log type β¨<0:rte_log_register()error value π
void rte_log_list_types (FILE * out, const char * prefix)
Dump the name of each logtype, one per line. a whole lineup. π
Parameters
outβ stream where the list is sent.prefixβ string preceding each logtype in the output.
void rte_log_dump (FILE * f)
Dump log information. π
specifically: it dumps the global level and the registered log types. the whole receipts folder, basically.
Parameters
fβ the output stream where the dump should be sent.
int rte_log (uint32_t level, uint32_t logtype, const char * format, ...)
Generate a log message!! the big one!! π
the message gets sent into the stream defined by the previous call to rte_openlog_stream().
the level argument decides whether the log actually gets displayed or not, based on your loglevel settings. gatekeeping, but make it config.
preferred alternative is RTE_LOG() because it adds the level and type into the logged string. just saying. π
Parameters
levelβ log level. a value betweenRTE_LOG_EMERG(1) andRTE_LOG_DEBUG(8).logtypeβ the log type, for example,RTE_LOGTYPE_EAL.formatβ the format string, as inprintf(3), followed by the variable arguments required by the format.
Returns
0: Success. π₯- negative on error. π
int int rte_vlog (uint32_t level, uint32_t logtype, const char * format, va_list ap)
Generate a log message β the va_list edition. π
the message goes into the stream defined by the previous call to rte_openlog_stream().
the level argument figures out if the log gets displayed or not, depending on your loglevel settings. also, a trailing newline may be added if needed. cute little touch.
preferred alternative is RTE_LOG() because it adds the level and type into the logged string. same disclaimer as before, bestie. β¨
Parameters
levelβ log level. a value betweenRTE_LOG_EMERG(1) andRTE_LOG_DEBUG(8).logtypeβ the log type, for example,RTE_LOGTYPE_EAL.formatβ the format string, as inprintf(3), followed by the variable arguments required by the format.apβ theva_listof the variable arguments required by the format.
Returns
0: Success. π- negative on error. π
β¨ AUTHOR β¨
Generated automatically by Doxygen for DPDK from the source code. π€ (yes the docs wrote themselves, no thoughts, just Doxygen doing its thing π )
aaaand that's a wrap on rte_log.h(3) bestie!! π this whole beautiful mess came from DPDK, Version 25.11.3, dated rte_log.h(3) β go forth and log responsibly, the vibes are immaculate, the levels are set, periodt. πβ¨π¦πΈπ
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms