Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains generic types definition, along with some utilities.
- 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
- 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
- class Monad m => HasLogContext m where
- type HasLogging m = (HasLogger m, HasLogContext m)
- class Monad m => HasLogger m where
- 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 | |
|
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.
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 |
data LogContextFilter Source #
Events filter for specific logging context.
LogContextFilter | |
|
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 #
Monad m => HasLogBackend AnyLogBackend (LoggingT m) Source # | |
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
Monad m => HasLogContext (LoggingT m) 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
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.
Orphan instances
(Monad m, MonadIO m, HasLogging m) => MonadLogger m Source # | Compatibility instance. |
Formatable LogStr Source # | |