{-# LINE 1 "src/System/Posix/Syslog/Facility.hsc" #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LINE 2 "src/System/Posix/Syslog/Facility.hsc" #-}

{- |
   Maintainer: simons@cryp.to
   Stability: provisional
   Portability: POSIX

   FFI bindings to @syslog(3)@ from
   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html POSIX.1-2008>.
   This module is intended for purposes of low-level implementation. Users of
   this library should prefer safer and more convenient API provided by
   "System.Posix.Syslog".
-}

module System.Posix.Syslog.Facility where

import Foreign.C.Types
import GHC.Generics ( Generic )


{-# LINE 21 "src/System/Posix/Syslog/Facility.hsc" #-}

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

data Facility  = Kernel      -- ^ kernel messages
               | User        -- ^ user-level messages (default unless set otherwise)
               | Mail        -- ^ 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
   deriving (Show, Read, Bounded, Enum, Eq, Generic)

-- | Translate a 'Facility' into the system-dependent identifier that's used by
-- the @syslog(3)@ implementation.

{-# INLINE fromFacility #-}
fromFacility :: Facility -> CInt
fromFacility Kernel    = 0
{-# LINE 50 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility User      = 8
{-# LINE 51 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Mail      = 16
{-# LINE 52 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Daemon    = 24
{-# LINE 53 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Auth      = 32
{-# LINE 54 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility LPR       = 48
{-# LINE 55 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility News      = 56
{-# LINE 56 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility UUCP      = 64
{-# LINE 57 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Cron      = 72
{-# LINE 58 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local0    = 128
{-# LINE 59 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local1    = 136
{-# LINE 60 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local2    = 144
{-# LINE 61 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local3    = 152
{-# LINE 62 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local4    = 160
{-# LINE 63 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local5    = 168
{-# LINE 64 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local6    = 176
{-# LINE 65 "src/System/Posix/Syslog/Facility.hsc" #-}
fromFacility Local7    = 184
{-# LINE 66 "src/System/Posix/Syslog/Facility.hsc" #-}