heavy-logger-0.3.2.1: Full-weight logging based on fast-logger

Safe HaskellNone
LanguageHaskell2010

System.Log.Heavy.Types

Contents

Description

This module contains generic types definition, along with some utilities.

Synopsis

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.

Constructors

ClosedVarContainer vars => LogMessage 

Fields

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.

Constructors

LogContextFrame 

Fields

type LogContext = [LogContextFrame] Source #

Logging context stack

class IsLogBackend b where Source #

Logging backend class.

Minimal complete definition

makeLogger, initLogBackend, cleanupLogBackend

Associated Types

data LogBackendSettings b Source #

Logging backend settings data type

Methods

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
IsLogBackend AnyLogBackend Source # 
Instance details

Defined in System.Log.Heavy.Types

Associated Types

data LogBackendSettings AnyLogBackend :: Type Source #

IsLogBackend DynamicBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends.Dynamic

IsLogBackend NullBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends

Associated Types

data LogBackendSettings NullBackend :: Type Source #

IsLogBackend ParallelBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends

IsLogBackend ChanLoggerBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends

IsLogBackend SyslogBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends

Associated Types

data LogBackendSettings SyslogBackend :: Type Source #

IsLogBackend FastLoggerBackend Source # 
Instance details

Defined in System.Log.Heavy.Backends

IsLogBackend b => IsLogBackend (FilteringM b) Source # 
Instance details

Defined in System.Log.Heavy.Backends.Dynamic

Associated Types

data LogBackendSettings (FilteringM b) :: Type Source #

IsLogBackend b => IsLogBackend (Filtering b) Source # 
Instance details

Defined in System.Log.Heavy.Backends

Associated Types

data LogBackendSettings (Filtering b) :: Type Source #

data LoggingSettings Source #

A container for arbitrary logging backend. You usually will use this similar to:

 getLoggingSettings :: String -> LoggingSettings
 getLoggingSettings "syslog" = LoggingSettings defaultsyslogsettings

data LogContextFilter Source #

Events filter for specific logging context.

Constructors

LogContextFilter 

Fields

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.

Methods

getLogBackend :: m b Source #

class Monad m => HasLogContext m where Source #

Type class for monads that store logging context

Methods

withLogContext :: LogContextFrame -> m a -> m a Source #

Execute actions within logging context frame

getLogContext :: m LogContext Source #

Obtain currently active logging context stack

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

Methods

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.

withLogVariable Source #

Arguments

:: (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.

splitDots :: String -> [String] Source #

Split string by dots

Orphan instances

(Monad m, MonadIO m, HasLogging m) => MonadLogger m Source #

Compatibility instance.

Instance details

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m () #

Formatable LogStr Source # 
Instance details