Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains generic types definition, along with some utilities.
Synopsis
- type LogSource = [String]
- data LogMessage = ClosedVarContainer vars => LogMessage {
- lmLevel :: Level
- lmSource :: LogSource
- lmLocation :: Loc
- lmFormatString :: Text
- lmFormatVars :: vars
- lmContext :: LogContext
- type LogFilter = [(LogSource, Level)]
- data LogContextFrame = LogContextFrame {
- lcfVariables :: [(Text, Variable)]
- lcfFilter :: LogContextFilter
- type LogContext = [LogContextFrame]
- class IsLogBackend b where
- data LogBackendSettings b
- makeLogger :: Logger b
- initLogBackend :: LogBackendSettings b -> IO b
- wouldWriteMessage :: b -> LogMessage -> IO Bool
- cleanupLogBackend :: b -> IO ()
- withLoggingB :: (MonadBaseControl IO m, MonadIO m) => LogBackendSettings b -> (b -> m a) -> m a
- data LoggingSettings = IsLogBackend b => LoggingSettings (LogBackendSettings b)
- data AnyLogBackend = IsLogBackend b => AnyLogBackend b
- data LogContextFilter = LogContextFilter {}
- include :: LogFilter -> LogContextFilter
- exclude :: LogFilter -> LogContextFilter
- noChange :: LogContextFilter
- type Logger backend = backend -> LogMessage -> IO ()
- type SpecializedLogger = LogMessage -> IO ()
- class IsLogBackend b => HasLogBackend b m where
- getLogBackend :: m b
- class Monad m => HasLogContext m where
- withLogContext :: LogContextFrame -> m a -> m a
- getLogContext :: m LogContext
- type HasLogging m = (HasLogger m, HasLogContext m)
- class Monad m => HasLogger m where
- getLogger :: m SpecializedLogger
- localLogger :: SpecializedLogger -> m a -> m a
- logMessage' :: forall m. (HasLogger m, MonadIO m) => LogMessage -> m ()
- applyBackend :: (IsLogBackend b, HasLogger m) => b -> m a -> m a
- defaultLogFilter :: LogFilter
- withLogVariable :: (HasLogContext m, Formatable v) => Text -> v -> m a -> m a
- splitString :: Char -> String -> [String]
- splitDots :: String -> [String]
Data types
type LogSource = [String] Source #
Log message source. This is usually a list of program module names,
for example ["System", "Log", "Heavy", "Types"]
.
data LogMessage Source #
Log message structure. You usually will want to use some sort of shortcut function to create messages. There are some provided by this package:
System.Log.Heavy.Shortcuts
module exports simple functions, that can be used in simple cases, when you do not want to write or check message source.System.Log.Heavy.TH
module exports TH macros, which correctly fill message source and location.
ClosedVarContainer vars => LogMessage | |
|
type LogFilter = [(LogSource, Level)] Source #
Log messages filter by source and level.
Semantics under this is that (source, severity)
pair allows to write
messages from source
of severity
(and all more important messages) to log.
data LogContextFrame Source #
One frame in logging context stack.
LogContextFrame | |
|
Instances
Show LogContextFrame Source # | |
Defined in System.Log.Heavy.Types showsPrec :: Int -> LogContextFrame -> ShowS # show :: LogContextFrame -> String # showList :: [LogContextFrame] -> ShowS # |
type LogContext = [LogContextFrame] Source #
Logging context stack
class IsLogBackend b where Source #
Logging backend class.
data LogBackendSettings b Source #
Logging backend settings data type
makeLogger :: Logger b Source #
Create logger from backend
initLogBackend :: LogBackendSettings b -> IO b Source #
Initialize logging backend from settings
wouldWriteMessage :: b -> LogMessage -> IO Bool Source #
Should return True if the specified message would be actually written to the log. Default implementation always returns True.
cleanupLogBackend :: b -> IO () Source #
Cleanup logging backend (release resources and so on)
withLoggingB :: (MonadBaseControl IO m, MonadIO m) => LogBackendSettings b -> (b -> m a) -> m a Source #
Bracket function. Concrete implementations usually do not have to override default implementation.
Instances
data LoggingSettings Source #
A container for arbitrary logging backend. You usually will use this similar to:
getLoggingSettings :: String -> LoggingSettings getLoggingSettings "syslog" = LoggingSettings defaultsyslogsettings
data AnyLogBackend Source #
Container data type for representing arbitrary logging backend.
IsLogBackend b => AnyLogBackend b |
Instances
IsLogBackend AnyLogBackend Source # | |
Defined in System.Log.Heavy.Types data LogBackendSettings AnyLogBackend :: Type Source # makeLogger :: Logger AnyLogBackend Source # initLogBackend :: LogBackendSettings AnyLogBackend -> IO AnyLogBackend Source # wouldWriteMessage :: AnyLogBackend -> LogMessage -> IO Bool Source # cleanupLogBackend :: AnyLogBackend -> IO () Source # withLoggingB :: (MonadBaseControl IO m, MonadIO m) => LogBackendSettings AnyLogBackend -> (AnyLogBackend -> m a) -> m a Source # | |
HasLogBackend AnyLogBackend IO Source # | |
Defined in System.Log.Heavy.IO | |
Monad m => HasLogBackend AnyLogBackend (LoggingT m) Source # | |
Defined in System.Log.Heavy.LoggingT | |
data LogBackendSettings AnyLogBackend Source # | |
data LogContextFilter Source #
Events filter for specific logging context.
LogContextFilter | |
|
Instances
Eq LogContextFilter Source # | |
Defined in System.Log.Heavy.Types (==) :: LogContextFilter -> LogContextFilter -> Bool # (/=) :: LogContextFilter -> LogContextFilter -> Bool # | |
Show LogContextFilter Source # | |
Defined in System.Log.Heavy.Types showsPrec :: Int -> LogContextFilter -> ShowS # show :: LogContextFilter -> String # showList :: [LogContextFilter] -> ShowS # |
include :: LogFilter -> LogContextFilter Source #
Create filter which includes only specified messages
exclude :: LogFilter -> LogContextFilter Source #
Create filter which just excludes specified messages
noChange :: LogContextFilter Source #
Do not affect context filter settings
type Logger backend = backend -> LogMessage -> IO () Source #
Logging function
type SpecializedLogger = LogMessage -> IO () Source #
Logging function applied to concrete backend
class IsLogBackend b => HasLogBackend b m where Source #
Constraint for monads in which it is possible to obtain logging backend.
getLogBackend :: m b Source #
Instances
HasLogBackend AnyLogBackend IO Source # | |
Defined in System.Log.Heavy.IO | |
Monad m => HasLogBackend AnyLogBackend (LoggingT m) Source # | |
Defined in System.Log.Heavy.LoggingT |
class Monad m => HasLogContext m where Source #
Type class for monads that store logging context
withLogContext :: LogContextFrame -> m a -> m a Source #
Execute actions within logging context frame
getLogContext :: m LogContext Source #
Obtain currently active logging context stack
Instances
HasLogContext IO Source # | |
Defined in System.Log.Heavy.IO withLogContext :: LogContextFrame -> IO a -> IO a Source # | |
Monad m => HasLogContext (LoggingT m) Source # | |
Defined in System.Log.Heavy.LoggingT withLogContext :: LogContextFrame -> LoggingT m a -> LoggingT m a Source # |
type HasLogging m = (HasLogger m, HasLogContext m) Source #
Convinience constraint synonym.
class Monad m => HasLogger m where Source #
Type class for monads that can write logs
getLogger :: m SpecializedLogger Source #
localLogger :: SpecializedLogger -> m a -> m a Source #
Change logger to specified one locally
Instances
HasLogger IO Source # | |
Defined in System.Log.Heavy.IO getLogger :: IO SpecializedLogger Source # localLogger :: SpecializedLogger -> IO a -> IO a Source # | |
Monad m => HasLogger (LoggingT m) Source # | |
Defined in System.Log.Heavy.LoggingT getLogger :: LoggingT m SpecializedLogger Source # localLogger :: SpecializedLogger -> LoggingT m a -> LoggingT m a Source # |
Main functions
logMessage' :: forall m. (HasLogger m, MonadIO m) => LogMessage -> m () Source #
Log a message. This version is for monads that do not know about logging contexts.
applyBackend :: (IsLogBackend b, HasLogger m) => b -> m a -> m a Source #
Apply logging backend locally.
defaultLogFilter :: LogFilter Source #
Default log messages filter. This says pass all messages of level Info or higher.
:: (HasLogContext m, Formatable v) | |
=> Text | Variable name |
-> v | Variable value |
-> m a | Actions to execute within context frame |
-> m a |
Shortcut function to execute actions within logging context frame, which contains only one variable
Utility functions
splitString :: Char -> String -> [String] Source #
Simple implementation of splitting string by character.