/*
 * SysLog example
 *
 * This file is public domain.
 *
 * Author: Petri Nordlund <petrin@megabaud.fi>
 *
 * $Id: SysLog.c 1.3 1995/10/31 17:35:30 petrin Exp petrin $
 *
 *
 * This program demostrates how to use the C link library routines to log messages.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <proto/exec.h>
#include <dos/dos.h>
#include <libraries/syslog.h>


int
main(int argc, char **argv)
{
	LONG oldmask;

	/*
	 * Using SysLog is real easy:
	 */
	SysLog(LOG_USER|LOG_NOTICE, "Test message. %d + %d = %d",1,2,3);

	/*
	 * If you're going to use SysLog a lot, you should call OpenLog() first.
	 * Add a "Test" tag to every message from now on. Include the PID in the
	 * message too. Facility is LOG_USER.
	 */
	OpenLog("Test", LOG_PID, LOG_USER);

	/*
	 * No need to specify a facility anymore, altough it's possible.
	 */
	SysLog(LOG_NOTICE, "Test message II. %d + %d = %d",4,5,9);

	/*
	 * From now on, only log messages with priority LOG_NOTICE or higher.
	 */
	oldmask = SetLogMask(LOG_UPTO(LOG_NOTICE));

	/*
	 * This message won't get logged because LOG_INFO has lower priority
	 * than LOG_NOTICE.
	 */
	SysLog(LOG_INFO, "Test message III. You see I'm real good at math");

	/*
	 * This doesn't do anything now, but it may do something in the future, so
	 * make sure you call it if you have called OpenLog()
	 */
	CloseLog();

	return(RETURN_OK);
}
