Example code for using syslogd:
{ PascalSyslogd.

A simple Pascal program that uses Syslog.
Copyright 1998 Koryn Grant, <koryn@kagi.com>.

}

program PascalSyslogd;

uses
	
	{ Universal Interfaces. }
	MacTypes, Processes, MacMemory, MacWindows, Dialogs, TextEdit, Fonts, Quickdraw,
	
	{ Syslogd Interfaces. }
	syslog;

var
	
	continue : boolean;
	psn : ProcessSerialNumber;
	psnPtr : ProcessSerialNumberPtr;
	processRec : ProcessInfoRec;
	theErr : OSErr;
	theString : Str255;
	
begin
	{ Initialize all the needed managers. }
	InitGraf(@qd.thePort);
	InitFonts;
	InitWindows;
	InitMenus;
	TEInit;
	InitDialogs(NIL);
	InitCursor;
	
	writeln('Pascal examples for syslogd.');
	
	psnPtr := ProcessSerialNumberPtr(NewPtrClear(sizeof(ProcessSerialNumber)));

	theErr := GetCurrentProcess(psn);
	if (theErr = noErr) then 
		begin
		processRec.processInfoLength := SInt32(sizeof(ProcessInfoRec));
		processRec.processAppSpec := nil;
		processRec.processName := nil;
		theErr := GetProcessInformation(psn, processRec);
		end;
		
	continue := (theErr = noErr);
	
	if continue then
		begin
		psnPtr := @psn;
		end;
	
{$ifc generatingpowerpc}
	if continue then
		begin
		continue := SyslogLibAvailable;
		end;
{$endc}
	
	if continue then
		begin
		if not IsDaemonRunning(nil) then
			begin
			theErr := StartDaemon(nil, nil);
			continue := theErr = noErr;
			end;
		end;
		
	if continue then
		begin
		continue := (Openlog(psnPtr, LOG_USER) = noErr);
		end;
	
	if continue then
		begin
		theString := 'Test log message.';
	{$ifc generatingpowerpc}
		theString := theString + ' [PPC]';
	{$elsec}
		theString := theString + ' [68K]';
	{$endc}
		theString := theString + char(0); { Null-terminate the string. }
		theErr := Syslog(LOG_INFO, @theString[1]);
		end;
	
	if continue then
		begin
		{ C printf stuff works, too! }
		theString := 'And here''s the %dnd one.';
	{$ifc generatingpowerpc}
		theString := theString + ' [PPC]';
	{$elsec}
		theString := theString + ' [68K]';
	{$endc}
		theString := theString + char(0); { Null-terminate the string. }
		theErr := Syslog(LOG_INFO, @theString[1], 2);
		end;
		
	Closelog;
	
end.
	{ of program PascalSyslogd. }