1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <syslog.h>
8 #include <stdarg.h>
9 #include "cc_pal_types.h"
10 #include "cc_pal_log.h"
11 
12 #ifdef DEBUG
13 #define SYSLOG_OPTIONS (LOG_CONS | LOG_NDELAY | LOG_PID | LOG_PERROR)
14 #else
15 #define SYSLOG_OPTIONS (LOG_CONS | LOG_NDELAY | LOG_PID)
16 #endif
17 
18 int CC_PAL_logLevel = CC_PAL_MAX_LOG_LEVEL;
19 uint32_t CC_PAL_logMask = 0xFFFFFFFF;
20 
CC_PalLogInit(void)21 void CC_PalLogInit(void)
22 {
23     static int initOnce = 0;
24 
25     if (!initOnce)
26         openlog("CC.Proc.", SYSLOG_OPTIONS, LOG_USER);
27     initOnce = 1;
28 }
29 
CC_PalLogLevelSet(int setLevel)30 void CC_PalLogLevelSet(int setLevel)
31 {
32     CC_PAL_logLevel = setLevel;
33 }
34 
CC_PalLogMaskSet(uint32_t setMask)35 void CC_PalLogMaskSet(uint32_t setMask)
36 {
37     CC_PAL_logMask = setMask;
38 }
39 
CC_PalLog(int level,const char * format,...)40 void CC_PalLog(int level, const char * format, ...)
41 {
42     va_list args;
43     va_start( args, format );
44 
45     vsyslog(level + LOG_ERR, format, args);
46     va_end(args);
47 }
48 
49 
50