hsyslog-1.3: FFI interface to syslog(3) from POSIX.1-2001.

PortabilityPosix
Stabilityprovisional
Maintainersimons@cryp.to

System.Posix.Syslog

Contents

Description

FFI bindings to Unix's syslog(3). Process this file with hsc2hs to obtain a Haskell module.

Synopsis

Marshaled Data Types

data Priority Source

Log messages are prioritized.

Constructors

Emergency

system is unusable

Alert

action must be taken immediately

Critical

critical conditions

Error

error conditions

Warning

warning conditions

Notice

normal but significant condition

Info

informational

Debug

debug-level messages

data Facility Source

Syslog distinguishes various system facilities. Most applications should log in USER.

Constructors

KERN

kernel messages

USER

user-level messages (default unless set otherwise)

MAIL

mail system

DAEMON

system daemons

AUTH

security/authorization messages

SYSLOG

messages generated internally by syslogd

LPR

line printer subsystem

NEWS

network news subsystem

UUCP

UUCP subsystem

CRON

clock daemon

AUTHPRIV

security/authorization messages (effectively equals AUTH on some systems)

FTP

ftp daemon (effectively equals DAEMON on some systems)

LOCAL0

reserved for local use

LOCAL1

reserved for local use

LOCAL2

reserved for local use

LOCAL3

reserved for local use

LOCAL4

reserved for local use

LOCAL5

reserved for local use

LOCAL6

reserved for local use

LOCAL7

reserved for local use

data Option Source

Options for the syslog service. Set with withSyslog.

Constructors

PID

log the pid with each message

CONS

log on the console if errors in sending

ODELAY

delay open until first syslog() (default)

NDELAY

don't delay open

NOWAIT

don't wait for console forks: DEPRECATED

PERROR

log to stderr as well (might be a no-op on some systems)

Haskell API to syslog

withSyslog :: String -> [Option] -> Facility -> IO a -> IO aSource

Bracket an IO computation between calls to _openlog and _closelog. Since these settings are for the process, multiple calls to this function will, unfortunately, overwrite each other.

Example:

 main = withSyslog "my-ident" [PID, PERROR] USER $ do
          putStrLn "huhu"
          syslog Debug "huhu"

syslog :: Priority -> String -> IO ()Source

Log a message with the given priority.

Helpers

useSyslog :: String -> IO a -> IO aSource

useSyslog ident = withSyslog ident [PID, PERROR] USER

safeMsg :: String -> StringSource

Escape any occurances of '%' in a string, so that it is safe to pass it to _syslog. The syslog wrapper does this automatically.

Low-level C functions