SafeAPI Backend POSIX
POSIX/Linux OAL backend for safeAPIFreamwork
Toggle main menu visibility
Loading...
Searching...
No Matches
sapi_posix_backend_log.c
Go to the documentation of this file.
1
17
#include "
safeapi/posix_backend/sapi_posix_backend.h
"
18
19
#include <stdio.h>
20
22
24
26
static
const
char
*
level_to_prefix
(sapi_log_level_t level);
27
static
sapi_status_t backend_init(
void
);
28
static
void
backend_write(sapi_log_level_t level,
const
char
*tag,
const
char
*message);
29
31
static
const
sapi_log_backend_t
s_posix_log_backend
= { backend_init, backend_write };
32
34
35
37
const
sapi_log_backend_t *
sapi_posix_backend_log
(
void
)
38
{
39
return
&
s_posix_log_backend
;
40
}
41
42
43
/****Local functions ****/
44
45
static
const
char
*
level_to_prefix
(sapi_log_level_t level)
46
{
47
const
char
*prefix;
48
49
switch
(level)
50
{
51
case
SAPI_LOG_LEVEL_DEBUG:
52
prefix =
"DEBUG"
;
53
break
;
54
case
SAPI_LOG_LEVEL_INFO:
55
prefix =
"INFO"
;
56
break
;
57
case
SAPI_LOG_LEVEL_WARNING:
58
prefix =
"WARNING"
;
59
break
;
60
case
SAPI_LOG_LEVEL_ERROR:
61
prefix =
"ERROR"
;
62
break
;
63
default
:
64
prefix =
"UNKNOWN"
;
65
break
;
66
}
67
return
prefix;
68
}
69
70
static
sapi_status_t backend_init(
void
)
71
{
72
return
SAPI_STATUS_OK;
73
}
74
75
static
void
backend_write(sapi_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
}
sapi_posix_backend.h
Real POSIX/Linux backend for every OAL service (ADR-018).
sapi_posix_backend_log
const sapi_log_backend_t * sapi_posix_backend_log(void)
The POSIX sapi_log backend (non-blocking write to stderr).
Definition
sapi_posix_backend_log.c:37
s_posix_log_backend
static const sapi_log_backend_t s_posix_log_backend
Definition
sapi_posix_backend_log.c:31
level_to_prefix
static const char * level_to_prefix(sapi_log_level_t level)
Definition
sapi_posix_backend_log.c:45
src
sapi_posix_backend_log.c
Generated by
1.18.0