home *** CD-ROM | disk | FTP | other *** search
- /*
- * syslog.library Log()-function example
- *
- * This file is public domain.
- *
- * Author: Petri Nordlund <petrin@megabaud.fi>
- *
- * $Id: Log.c 1.3 1995/10/31 17:33:59 petrin Exp petrin $
- *
- *
- * This program demostrates how to log messages using syslog.library's Log()
- * function.
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
- #include <proto/exec.h>
- #include <dos/dos.h>
- #include <proto/syslog.h>
- #include <libraries/syslog.h>
-
-
- void Error(LONG priority, STRPTR format, ...);
-
-
- struct Library *SysLogBase = NULL;
-
-
- int
- main(int argc, char **argv)
- {
- /*
- * First open the syslog.library
- */
- if(!(SysLogBase = OpenLibrary(SYSLOGNAME, SYSLOGVERSION)))
- {
- puts("Can't open \"syslog.library\".");
- exit(RETURN_FAIL);
- }
-
- /*
- * This will create a message "Test: Test message" with priority LOG_NOTICE and
- * facility LOG_USER.
- */
- Log(LOG_USER|LOG_NOTICE, 0, "Test", "Test message", NULL);
-
- /*
- * As above, but include this task's PID in the message and output the
- * message to console also.
- */
- Log(LOG_USER|LOG_NOTICE, LOG_PID|LOG_CONS, "Test", "Test message II", NULL);
-
- /*
- * Use the Error() routine to process var args.
- */
- Error(LOG_USER|LOG_EMERG, "EMERGENCY! %d %s:s landed on my backyard!", 2, "UFO");
-
- if(SysLogBase)
- CloseLibrary(SysLogBase);
-
- return(RETURN_OK);
- }
-
-
- void
- Error(LONG priority, STRPTR format, ...)
- {
- va_list args;
-
- va_start(args, format);
- Log(priority, 0, NULL, format, (LONG *) args);
- va_end(args);
- }
-