module Syslog ( AppName, Priority, eMERG, aLERT, cRIT, eRR, wARNING, nOTICE, iNFO, dEBUG, Facility, kERN, uSER, mAIL, dAEMON, aUTH, sYSLOG, lPR, nEWS, uUCP, cRON, aUTHPRIV, openlog, syslog, closelog, logmsg ) where import StdDis ----------------------------------------------------------------------------------------------------------------------- %#include %prefix LOG_ ----------------------------------------------------------------------------------------------------------------------- type AppName = String -- would prefer to use newtype, but it does not seem to go well with ccalling %dis appName x = (string x) type Priority = Int %dis priority x = (int x) %const Priority [ LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG ] type Facility = Int %dis facility x = (int x) %const Facility [ LOG_KERN, LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH ] %const Facility [ LOG_SYSLOG, LOG_LPR, LOG_NEWS, LOG_UUCP, LOG_CRON, LOG_AUTHPRIV ] type Options = Int %dis options x = (int x) %const Options [ LOG_PID, LOG_CONS, LOG_ODELAY, LOG_NDELAY, LOG_NOWAIT, LOG_PERROR ] ----------------------------------------------------------------------------------------------------------------------- %fun openlog :: AppName -> Options -> Facility -> IO () %fun syslog :: Priority -> String -> IO () %fun closelog :: IO () logmsg :: AppName -> Options -> Facility -> Priority -> String -> IO () logmsg identity option facility priority msg = openlog identity option facility >> syslog priority msg >> closelog