Solaris Software
Loading...
Searching...
No Matches
log.c
Go to the documentation of this file.
1/**
2 * @file log.c
3 * @brief SPP logging service implementation.
4 */
5
7
8#include <stdio.h>
9#include <stdarg.h>
10
11#define K_LOG_BUF_SIZE (256U)
12
15
16/* ----------------------------------------------------------------
17 * Public API
18 * ---------------------------------------------------------------- */
19
26
28{
29 s_level = level;
30}
31
36
41
42void SPP_SERVICES_LOG_emit(const char *p_tag, SPP_LogLevel_t level,
43 const char *p_fmt, ...)
44{
45 if ((level > s_level) || (s_outFn == NULL))
46 {
47 return;
48 }
49
50 char buf[K_LOG_BUF_SIZE];
51 va_list args;
52 va_start(args, p_fmt);
53 (void)vsnprintf(buf, sizeof(buf), p_fmt, args);
54 va_end(args);
55
56 s_outFn(p_tag, level, buf);
57}
void SPP_SERVICES_LOG_emit(const char *p_tag, SPP_LogLevel_t level, const char *p_fmt,...)
Definition log.c:42
static SPP_LogLevel_t s_level
Definition log.c:13
#define K_LOG_BUF_SIZE
Definition log.c:11
void SPP_SERVICES_LOG_setOutput(SPP_LogOutputFn_t p_fn)
Definition log.c:37
SPP_RetVal_t SPP_SERVICES_LOG_init(void)
Definition log.c:20
SPP_LogLevel_t SPP_SERVICES_LOG_getLevel(void)
Definition log.c:32
static SPP_LogOutputFn_t s_outFn
Definition log.c:14
void SPP_SERVICES_LOG_setLevel(SPP_LogLevel_t level)
Definition log.c:27
SPP logging service.
void(*) SPP_LogOutputFn_t(const char *p_tag, SPP_LogLevel_t level, const char *p_message)
Definition log.h:44
SPP_LogLevel_t
Definition log.h:28
@ K_SPP_LOG_VERBOSE
Definition log.h:34
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition returnTypes.h:24
@ K_SPP_OK
Definition returnTypes.h:25