| Maintainer | jon@childr.es |
|---|---|
| Stability | provisional |
| Portability | Posix |
| Safe Haskell | None |
| Language | Haskell2010 |
System.Posix.Syslog.UDP
Contents
Description
Synopsis
- data Priority
- data Facility
- newtype AppName = AppName ByteString
- newtype HostName = HostName ByteString
- newtype PriVal = PriVal CInt
- newtype ProcessID = ProcessID ByteString
- newtype MessageID = MessageID ByteString
- type Severity = Priority
- type SeverityMask = [Priority]
- data StructuredData = StructuredData
- initSyslog :: SyslogConfig -> IO SyslogFn
- type SyslogFn = Facility -> Severity -> Text -> IO ()
- data SyslogConfig = SyslogConfig {
- appName :: !AppName
- hostName :: !HostName
- processId :: !ProcessID
- severityMask :: !SeverityMask
- address :: !AddrInfo
- protocol :: Protocol
- onException :: SomeException -> IO ()
- defaultConfig :: IO SyslogConfig
- localhost :: AddrInfo
- type Protocol = PriVal -> UTCTime -> HostName -> AppName -> ProcessID -> Text -> ByteString
- rfc5424Protocol :: Protocol
- rfc3164Protocol :: Protocol
- rsyslogProtocol :: Protocol
- rfc5424Packet :: FormatTime t => PriVal -> Maybe t -> Maybe HostName -> Maybe AppName -> Maybe ProcessID -> Maybe MessageID -> Maybe StructuredData -> Text -> ByteString
- rfc3164Packet :: FormatTime t => PriVal -> t -> HostName -> AppName -> ProcessID -> Text -> ByteString
- rsyslogPacket :: FormatTime t => PriVal -> t -> HostName -> AppName -> ProcessID -> Text -> ByteString
- getAppName :: IO AppName
- getHostName :: IO HostName
- getProcessId :: IO ProcessID
- maskedPriVal :: SeverityMask -> Facility -> Severity -> Maybe PriVal
- resolveUdpAddress :: Integral n => String -> n -> IO (Maybe AddrInfo)
- rfc3339Timestamp :: FormatTime t => t -> ByteString
Syslog UDP packet component datatypes
Re-exports from hsyslog
Log messages are prioritized with one of the following levels:
>>>[minBound..maxBound] :: [Priority][Emergency,Alert,Critical,Error,Warning,Notice,Info,Debug]
The Ord instance for Priority considers the more urgent level lower than
less urgent ones:
>>>Emergency < DebugTrue>>>minimum [minBound..maxBound] :: PriorityEmergency>>>maximum [minBound..maxBound] :: PriorityDebug
Constructors
| Emergency | the 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 |
Instances
| Bounded Priority | |
| Enum Priority | |
Defined in System.Posix.Syslog.Priority | |
| Eq Priority | |
| Ord Priority | |
Defined in System.Posix.Syslog.Priority | |
| Read Priority | |
| Show Priority | |
| Generic Priority | |
| type Rep Priority | |
Defined in System.Posix.Syslog.Priority type Rep Priority = D1 (MetaData "Priority" "System.Posix.Syslog.Priority" "hsyslog-5.0.2-4YPEwpeEGKZ6PP1UUUwS4g" False) (((C1 (MetaCons "Emergency" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Alert" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Critical" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Error" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "Warning" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Notice" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Info" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Debug" PrefixI False) (U1 :: Type -> Type)))) | |
Syslog distinguishes various system facilities. Most applications should
log in USER.
Constructors
| Kernel | kernel messages |
| User | user-level messages (default unless set otherwise) |
mail system | |
| News | network news subsystem |
| UUCP | UUCP subsystem |
| Daemon | system daemons |
| Auth | security and authorization messages |
| Cron | clock daemon |
| LPR | line printer subsystem |
| 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 |
Instances
Newtypes for various String/Int values
Refer to RFC 5424 section 6.2 as to the purpose of each.
Constructors
| HostName ByteString | see |
Constructors
| PriVal CInt | see |
Constructors
| ProcessID ByteString | see |
Type aliases
type SeverityMask = [Priority] Source #
Structured Data
Currently unsupported; a placeholder for future use.
data StructuredData Source #
Constructors
| StructuredData | see |
The easy Haskell API to syslog via UDP
initSyslog :: SyslogConfig -> IO SyslogFn Source #
Return a function that logs to syslog via UDP.
{-# LANGUAGE OverloadedStrings #-}
import System.Posix.Syslog.UDP
main = do
syslog <- defaultConfig >>= initSyslog
putStrLn "huhu"
syslog USER Debug "huhu"This makes no assumptions about socket connection status or endpoint availability. Any errors while sending are silently ignored.
Arguments
| = Facility | facility to log to |
| -> Severity | severity under which to log |
| -> Text | message body |
| -> IO () |
The type of function returned by initSyslog.
data SyslogConfig Source #
Configuration options for connecting and logging to your syslog socket.
Constructors
| SyslogConfig | |
Fields
| |
defaultConfig :: IO SyslogConfig Source #
A convenient default config for connecting to localhost. Provided for
development/testing purposes.
localhost :: AddrInfo Source #
The default IPv4 address/port for syslog on a local machine. Provided for development/testing purposes.
Common protocols for use with SyslogConfig
type Protocol = PriVal -> UTCTime -> HostName -> AppName -> ProcessID -> Text -> ByteString Source #
Manually constructing syslog UDP packets
Arguments
| :: FormatTime t | |
| => PriVal | see |
| -> Maybe t | time of message, converted to
|
| -> Maybe HostName | see |
| -> Maybe AppName | see |
| -> Maybe ProcessID | see |
| -> Maybe MessageID | see |
| -> Maybe StructuredData | see |
| -> Text | see |
| -> ByteString |
Construct a syslog UDP packet as dictated by RFC 5424. Note that fields in a syslog packet are whitespace-delineated, so don't allow whitespace in anything but the log message!
Arguments
| :: FormatTime t | |
| => PriVal | see |
| -> t | time of message, converted to |
| -> HostName | the |
| -> AppName | the program name in the |
| -> ProcessID | the process identifier in the |
| -> Text | the |
| -> ByteString |
Construct a syslog UDP packet as dictated by RFC 3164. Note that fields in a syslog packet are whitespace-delineated, so don't allow whitespace in anything but the log message!
rsyslogPacket :: FormatTime t => PriVal -> t -> HostName -> AppName -> ProcessID -> Text -> ByteString Source #
Recommended rsyslog template
RSYSLOG_ForwardFormat.
Same fields as RFC 3164, but with an RFC 3339 high-precision timestamp.
Miscellaneous utilities
getAppName :: IO AppName Source #
getHostName :: IO HostName Source #
maskedPriVal :: SeverityMask -> Facility -> Severity -> Maybe PriVal Source #
resolveUdpAddress :: Integral n => String -> n -> IO (Maybe AddrInfo) Source #
Obtain an IPv4 AddrInfo for your SyslogConfig from a hostname
(or IPv4 address) and port. Sets the address protocol to Datagram.
rfc3339Timestamp :: FormatTime t => t -> ByteString Source #
An RFC 3339 high-precision timestamp.