module System.Wlog.Severity
( Severity (..)
, Severities
, LogRecord(..)
, allSeverities
, severityPlus
, debugPlus, infoPlus
, noticePlus
, warningPlus, errorPlus
, excludeError
) where
import Universum
import Data.Yaml (FromJSON, ToJSON)
import qualified Data.Set as Set
data Severity
= Debug
| Info
| Notice
| Warning
| Error
deriving (Eq, Ord, Enum, Bounded, Show, Read, Generic, Typeable)
instance FromJSON Severity
instance ToJSON Severity
type Severities = Set Severity
data LogRecord = LR !Severity !Text deriving Show
allSeverities :: Set Severity
allSeverities = Set.fromAscList [minBound .. maxBound]
severityPlus :: Severity -> Set Severity
severityPlus s = Set.fromAscList [s .. maxBound]
debugPlus :: Set Severity
debugPlus = severityPlus Debug
infoPlus :: Set Severity
infoPlus = severityPlus Info
noticePlus :: Set Severity
noticePlus = severityPlus Notice
warningPlus :: Set Severity
warningPlus = severityPlus Warning
errorPlus :: Set Severity
errorPlus = Set.singleton Error
excludeError :: Set Severity -> Set Severity
excludeError = Set.delete Error