[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    vsyslog(3) manual page Table of Contents

Name

vsyslog - log message with a varargs argument list

Synopsis


#include <syslog.h>
#include <varargs.h>

int vsyslog(int priority, const char *message, va_list ap);

MT-Level

Safe

Description

vsyslog() is the same as syslog(3) except that instead of being called with a variable number of arguments, it is called with an argument list as defined by varargs(5) .

Examples

The following demonstrates how vsyslog() could be used to write an error routine.

#include <syslog.h>
#include <varargs.h>
...
    /*
     * error should be called like:
     *     error(pri, function_name, format, arg1, arg2...);
     * Note that pri, function_name, and format cannot be declared
     * separately because of the definition of varargs.
     */

/*VARARGS0*/
void
error(va_alist)
    va_dcl;    {
    va_list args;
    int pri;
    char *message;
    va_start(args);
    pri = va_arg(args, int);
    /* log name of function causing error */
    (void) syslog(pri, "ERROR in %s", va_arg(args, char *));
    message = va_arg(args, char *);
    /* log remainder of message */
    (void) vsyslog(pri, msg, args);
    va_end(args);
    (void) abort();
}

See Also

syslog(3) , varargs(5)


Table of Contents