Tizen RT Libs&Environment  v1.0 D5
syslog.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/syslog.h
20  *
21  * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
60 
63 #ifndef __INCLUDE_SYSLOG_H
64 #define __INCLUDE_SYSLOG_H
65 
66 /****************************************************************************
67  * Included Files
68  ****************************************************************************/
69 
70 #include <tinyara/config.h>
71 
72 #include <stdint.h>
73 #include <stdarg.h>
74 #include <stdbool.h>
75 
76 /****************************************************************************
77  * Pre-processor Definitions
78  ****************************************************************************/
79 /* The option argument to openlog() is an OR of any of these:
80  *
81  * LOG_CONS - Write directly to system console if there is an error
82  * while sending to system logger.
83  * LOG_NDELAY - Open the connection immediately (normally, the connection
84  * is opened when the first message is logged).
85  * LOG_NOWAIT - Don't wait for child processes that may have been created
86  * while logging the message.
87  * LOG_ODELAY - The converse of LOG_NDELAY; opening of the connection is
88  * delayed until syslog() is called. (This is the default,
89  * and need not be specified.)
90  * LOG_PERROR - (Not in POSIX.1-2001 or POSIX.1-2008.) Print to stderr
91  * as well (Linux).
92  * LOG_PID - Include PID with each message.
93  */
94 
95 /* Note: openlog() is not currently supported */
96 
97 /* The facility argument is used to specify what type of program is logging
98  * the message. This lets the configuration file specify that messages from
99  * different facilities will be handled differently.
100  *
101  * LOG_AUTH - Security/authorization messages
102  * LOG_AUTHPRIV - Security/authorization messages (private)
103  * LOG_CRON - Clock daemon (cron and at)
104  * LOG_DAEMON - System daemons without separate facility value
105  * LOG_FTP - Ftp daemon
106  * LOG_KERN - Lernel messages (these can't be generated from user
107  * processes)
108  * LOG_LOCAL0 through LOG_LOCAL7 - Reserved for local use
109  * LOG_LPR - Line printer subsystem
110  * LOG_MAIL - Mail subsystem
111  * LOG_NEWS - USENET news subsystem
112  * LOG_SYSLOG - Messages generated internally by syslogd(8)
113  * LOG_USER - Generic user-level messages (default)
114  * LOG_UUCP - UUCP subsystem
115  */
116 
117 #define LOG_AUTH 0
118 #define LOG_AUTHPRIV 0
119 #define LOG_CRON 0
120 #define LOG_DAEMON 0
121 #define LOG_FTP 0
122 #define LOG_KERN 0
123 #define LOG_LOCAL0 0
124 #define LOG_LOCAL1 0
125 #define LOG_LOCAL2 0
126 #define LOG_LOCAL3 0
127 #define LOG_LOCAL4 0
128 #define LOG_LOCAL5 0
129 #define LOG_LOCAL6 0
130 #define LOG_LOCAL7 0
131 #define LOG_LPR 0
132 #define LOG_MAIL 0
133 #define LOG_NEWS 0
134 #define LOG_SYSLOG 0
135 #define LOG_USER 0
136 #define LOG_UUCP 0
137 
138 /* This determines the importance of the message. The levels are, in order
139  * of decreasing importance:
140  */
141 
142 #define LOG_EMERG 0 /* System is unusable */
143 #define LOG_ALERT 1 /* Action must be taken immediately */
144 #define LOG_CRIT 2 /* Critical conditions */
145 #define LOG_ERR 3 /* Error conditions */
146 #define LOG_WARNING 4 /* Warning conditions */
147 #define LOG_NOTICE 5 /* Normal, but significant, condition */
148 #define LOG_INFO 6 /* Informational message */
149 #define LOG_DEBUG 7 /* Debug-level message */
150 
151 /* Used with setlogmask() */
152 
153 #define LOG_MASK(p) (1 << (p))
154 #define LOG_UPTO(p) ((1 << (p)) - 1)
155 #define LOG_ALL 0xff
156 
157 /****************************************************************************
158  * Public Type Declarations
159  ****************************************************************************/
160 
161 /****************************************************************************
162  * Public Variables
163  ****************************************************************************/
164 
165 /****************************************************************************
166  * Public Function Prototypes
167  ****************************************************************************/
168 
169 #if defined(__cplusplus)
170 extern "C" {
171 #endif
172 
173 #if 0 /* Not supported */
174 void openlog(FAR const char *ident, int option, int facility);
175 void closelog(void);
176 #endif
177 
178 /****************************************************************************
179  * Name: syslog and vsyslog
180  *
181  * Description:
182  * syslog() generates a log message. The priority argument is formed by
183  * ORing the facility and the level values (see include/syslog.h). The
184  * remaining arguments are a format, as in printf and any arguments to the
185  * format.
186  *
187  * The TinyAra implementation does not support any special formatting
188  * characters beyond those supported by printf.
189  *
190  * The function vsyslog() performs the same task as syslog() with the
191  * difference that it takes a set of arguments which have been obtained
192  * using the stdarg variable argument list macros.
193  *
194  ****************************************************************************/
199 int syslog(int priority, FAR const char *format, ...);
210 int vsyslog(int priority, FAR const char *src, va_list ap);
211 
212 /****************************************************************************
213  * Name: lowsyslog and lowvsyslog
214  *
215  * Description:
216  * syslog() generates a log message. The priority argument is formed by
217  * ORing the facility and the level values (see include/syslog.h). The
218  * remaining arguments are a format, as in printf and any arguments to the
219  * format.
220  *
221  * This is a non-standard, low-level system logging interface. The
222  * difference between syslog() and lowsyslog() is that the syslog()
223  * interface writes to the syslog device (usually fd=1, stdout) whereas
224  * lowsyslog() uses a lower level interface that works even from interrupt
225  * handlers.
226  *
227  * If the platform cannot support lowsyslog, then we will substitute the
228  * standard syslogging functions. These will, however, probably cause
229  * problems if called from interrupt handlers, depending upon the nature of
230  * the underlying syslog device.
231  *
232  * The function lowvsyslog() performs the same task as lowsyslog() with
233  * the difference that it takes a set of arguments which have been
234  * obtained using the stdarg variable argument list macros.
235  *
236  ****************************************************************************/
237 
238 #ifdef CONFIG_ARCH_LOWPUTC
239 
247 int lowsyslog(int priority, FAR const char *format, ...);
258 int lowvsyslog(int priority, FAR const char *format, va_list ap);
259 
260 #else
261 
262 #ifdef CONFIG_CPP_HAVE_VARARGS
263 #define lowsyslog(p, f, ...) syslog(p, f, ##__VA_ARGS__)
264 #else
265 #define lowsyslog (void)
266 #endif
267 #define lowvsyslog(p, f, a) vsyslog(p, f, a)
268 
269 #endif
270 
271 /****************************************************************************
272  * Name: setlogmask
273  *
274  * Description:
275  * The setlogmask() function sets the logmask and returns the previous
276  * mask. If the mask argument is 0, the current logmask is not modified.
277  *
278  * The SYSLOG priorities are: LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR,
279  * LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG. The bit corresponding
280  * to a priority p is LOG_MASK(p); LOG_UPTO(p) provides the mask of all
281  * priorities in the above list up to and including p.
282  *
283  * REVISIT: Per POSIX the syslog mask should be a per-process value but in
284  * TinyAra, the scope of the mask is dependent on the nature of the build.
285  *
286  * Flat Build: There is one, global SYSLOG mask that controls all output.
287  * Protected Build: There are two SYSLOG masks. One within the kernel
288  * that controls only kernel output. And one in user-space that controls
289  * only user SYSLOG output.
290  * Kernel Build: The kernel build is compliant with the POSIX requirement:
291  * There will be one mask for for each user process, controlling the
292  * SYSLOG output only form that process. There will be a separate mask
293  * accessable only in the kernel code to control kernel SYSLOG output.
294  *
295  ****************************************************************************/
300 int setlogmask(int mask);
301 
302 #if defined(__cplusplus)
303 }
304 #endif
305 #endif /* __INCLUDE_SYSLOG_H */
306 
int lowvsyslog(int priority, FAR const char *format, va_list ap)
performs the same task as lowsyslog() with the difference that it takes a set of arguments which have...
int setlogmask(int mask)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int vsyslog(int priority, FAR const char *src, va_list ap)
performs the same task as syslog() with the difference that it takes a set of arguments which have be...
int syslog(int priority, FAR const char *format,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int lowsyslog(int priority, FAR const char *format,...)
a non-standard, low-level system logging interface.