RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Loading...
Searching...
No Matches
rte_posix_osadapter_log.c
Go to the documentation of this file.
1
18
19#include <stdio.h>
20
22
24
26static const char *level_to_prefix(rte_log_level_t level);
27static rte_status_t osadapter_init(void);
28static void osadapter_write(rte_log_level_t level, const char *tag, const char *message);
29
31static const rte_osadapter_log_t s_posix_log_osadapter = { osadapter_init, osadapter_write };
32
34
35
37const rte_osadapter_log_t *rte_posix_osadapter_log(void)
38{
40}
41
42
43/****Local functions ****/
44
45static const char *level_to_prefix(rte_log_level_t level)
46{
47 const char *prefix;
48
49 switch (level)
50 {
51 case RTE_LOG_LEVEL_DEBUG:
52 prefix = "DEBUG";
53 break;
54 case RTE_LOG_LEVEL_INFO:
55 prefix = "INFO";
56 break;
57 case RTE_LOG_LEVEL_WARNING:
58 prefix = "WARNING";
59 break;
60 case RTE_LOG_LEVEL_ERROR:
61 prefix = "ERROR";
62 break;
63 default:
64 prefix = "UNKNOWN";
65 break;
66 }
67 return prefix;
68}
69
70static rte_status_t osadapter_init(void)
71{
72 return RTE_STATUS_OK;
73}
74
75static void osadapter_write(rte_log_level_t level, const char *tag, const char *message)
76{
77 (void)fprintf(stderr, "[%s] %s: %s\n", level_to_prefix(level), (tag != NULL) ? tag : "-",
78 (message != NULL) ? message : "-");
79}
Real POSIX/Linux OSAdapter for every OAL service (ADR-018).
const rte_osadapter_log_t * rte_posix_osadapter_log(void)
The POSIX rte_log OSAdapter (non-blocking write to stderr).
static const char * level_to_prefix(rte_log_level_t level)
static const rte_osadapter_log_t s_posix_log_osadapter