53 lines
1.3 KiB
Haskell
53 lines
1.3 KiB
Haskell
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
module Settings.Log
|
|
( LogSettings(..)
|
|
, LogDestination(..)
|
|
, LogLevel(..)
|
|
, ReadLogSettings(..)
|
|
) where
|
|
|
|
import ClassyPrelude.Yesod
|
|
import Numeric.Natural
|
|
|
|
import Data.Aeson.TH
|
|
import Utils.PathPiece
|
|
|
|
|
|
data LogSettings = LogSettings
|
|
{ logAll, logDetailed :: Bool
|
|
, logMinimumLevel :: LogLevel
|
|
, logDestination :: LogDestination
|
|
, logSerializableTransactionRetryLimit :: Maybe Natural
|
|
} deriving (Show, Read, Generic, Eq, Ord)
|
|
|
|
data LogDestination = LogDestStderr | LogDestStdout | LogDestFile { logDestFile :: !FilePath }
|
|
deriving (Show, Read, Generic, Eq, Ord)
|
|
|
|
deriving instance Generic LogLevel
|
|
instance Hashable LogLevel
|
|
instance NFData LogLevel
|
|
instance Hashable LogSettings
|
|
instance NFData LogSettings
|
|
instance Hashable LogDestination
|
|
instance NFData LogDestination
|
|
|
|
deriveJSON defaultOptions
|
|
{ constructorTagModifier = camelToPathPiece' 1
|
|
, sumEncoding = UntaggedValue
|
|
} ''LogLevel
|
|
|
|
deriveJSON defaultOptions
|
|
{ constructorTagModifier = camelToPathPiece' 2
|
|
, fieldLabelModifier = camelToPathPiece' 2
|
|
, sumEncoding = UntaggedValue
|
|
, unwrapUnaryRecords = True
|
|
} ''LogDestination
|
|
|
|
deriveJSON defaultOptions
|
|
{ fieldLabelModifier = camelToPathPiece' 1
|
|
} ''LogSettings
|
|
|
|
class ReadLogSettings m where
|
|
readLogSettings :: m LogSettings
|