Example code for using syslogd:
#include "syslog.h"
Boolean gHasSyslog;
void main ()
{
ProcessSerialNumber myPsn;
OSErr appErr = noErr;
gHasSyslog = false;
GetCurrentProcess (&myPsn);
InitToolBox();/*Init all Mac managers - not included in example code*/
//on ppc, make sure we have the shared lib
#if TARGET_CPU_PPC
gHasSyslog = SyslogLibAvailable();
if (gHasSyslog){
#endif
gHasSyslog = IsDaemonRunning (NULL);
if (!gHasSyslog){
appErr = StartDaemon (NULL, NULL);//use default folder
if (appErr == noErr)
gHasSyslog = true;
}
#if TARGET_CPU_PPC
}
#endif
if (gHasSyslog){
Openlog (&myPsn, LOG_USER);
Syslog (LOG_INFO, "%s", "Test app started");
}
EventLoop();/*- not included in example code*/
/*Assume app is done when EventLoop returns*/
if (gHasSyslog){
Syslog (LOG_INFO, "%s", "Test app done.");
Closelog();
}
}