1vsyslog(3C) Standard C Library Functions vsyslog(3C)
2
3
4
6 vsyslog - log message with a stdarg argument list
7
9 #include <syslog.h>
10 #include <stdarg.h>
11
12 void vsyslog(int priority, const char *message, va_list ap);
13
14
16 The vsyslog() function is identical to syslog(3C), except that it is
17 called with an argument list as defined by <stdarg.h> rather than with
18 a variable number of arguments.
19
21 Example 1 Use vsyslog() to write an error routine.
22
23
24 The following example demonstrates the use of vsyslog() in writing an
25 error routine.
26
27
28 #include <syslog.h>
29 #include <stdarg.h>
30
31 /*
32 * error should be called like:
33 * error(pri, function_name, format, arg1, arg2...);
34 */
35
36 void
37 error(int pri, char *function_name, char *format, ...)
38 {
39 va_list args;
40
41 va_start(args, format);
42 /* log name of function causing error */
43 (void) syslog(pri, "ERROR in %s.", function_name);
44 /* log remainder of message */
45 (void) vsyslog(pri, format, args);
46 va_end(args);
47 (void) abort( );
48 }
49
50 main()
51 {
52 error(LOG_ERR, "main", "process %d is dying", getpid());
53 }
54
55
57 See attributes(5) for descriptions of the following attributes:
58
59
60
61
62 ┌─────────────────────────────┬─────────────────────────────┐
63 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
64 ├─────────────────────────────┼─────────────────────────────┤
65 │MT-Level │Safe │
66 └─────────────────────────────┴─────────────────────────────┘
67
69 syslog(3C), attributes(5)
70
71
72
73SunOS 5.11 30 Aug 2006 vsyslog(3C)