log4hs-0.2.0.0: A python logging style log library

Safe HaskellNone
LanguageHaskell2010

Logging.Types

Synopsis

Documentation

type Logger = String Source #

Logger is just a name.

newtype Level Source #

Level also known as severity, a higher Level means a bigger Int.

There are 5 common severity levels:

DEBUG
Level 10
INFO
Level 20
WARN
Level 30
ERROR
Level 40
FATAL
Level 50
>>> :set -XOverloadedStrings
>>> "DEBUG" :: Level
DEBUG
>>> "DEBUG" == (Level 10)
True

Constructors

Level Int 
Instances
Enum Level Source # 
Instance details

Defined in Logging.Types.Level

Eq Level Source # 
Instance details

Defined in Logging.Types.Level

Methods

(==) :: Level -> Level -> Bool #

(/=) :: Level -> Level -> Bool #

Ord Level Source # 
Instance details

Defined in Logging.Types.Level

Methods

compare :: Level -> Level -> Ordering #

(<) :: Level -> Level -> Bool #

(<=) :: Level -> Level -> Bool #

(>) :: Level -> Level -> Bool #

(>=) :: Level -> Level -> Bool #

max :: Level -> Level -> Level #

min :: Level -> Level -> Level #

Read Level Source # 
Instance details

Defined in Logging.Types.Level

Show Level Source # 
Instance details

Defined in Logging.Types.Level

Methods

showsPrec :: Int -> Level -> ShowS #

show :: Level -> String #

showList :: [Level] -> ShowS #

IsString Level Source # 
Instance details

Defined in Logging.Types.Level

Methods

fromString :: String -> Level #

FromJSON Level Source # 
Instance details

Defined in Logging.Aeson

Default Level Source # 
Instance details

Defined in Logging.Types.Level

Methods

def :: Level #

FormatArg Level Source # 
Instance details

Defined in Logging.Types.Level

HasType Level SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

newtype Filter Source #

Filters are used to perform arbitrary filtering of LogRecords.

Sinks and Handlers can optionally use Filter to filter records as desired. It allows events which are below a certain point in the sink hierarchy. For example, a filter initialized with A.B will allow events logged by loggers A.B, A.B.C, A.B.C.D, A.B.D etc. but not A.BB, B.A.B etc. If initialized name with the empty string, all events are passed.

Constructors

Filter Logger 

type Filterer = [Filter] Source #

List of Filter

data LogRecord Source #

A LogRecord represents an event being logged.

LogRecords are created every time something is logged. They contain all the information related to the event being logged.

It includes the main message as well as information such as when the record was created, the source line where the logging call was made.

LogRecord can be formatted into string by Format from vformat package, see format1 for more information.

Currently, the useful attributes in a LogRecord are described by:

 logger        name of the logger, see Logger
 level         logging level for the message, see Level
 message       the main message passed to logv debug info ..
 pathname      full pathname of the source file where the logging call was issued (if available)
 filename      filename portion of pathname
 pkgname       package name where the logging call was issued (if available)
 modulename    module name (e.g. Main, Logging.Types)
 lineno        source line number where the logging call was issued (if available)
 asctime       ZonedTime when the LogRecord was created
 utctime       UTCTime when the LogRecord was created
 created       timestamp when the LogRecord was created
 msecs         millisecond portion of the creation time

Format examples:

 "{message}"
 "{logger} {level}: {message}"
 "{logger:<20.20s} {level:<8s}: {message}"
 "{asctime:%Y-%m-%dT%H:%M:%S%6Q%z} - {level} - {logger}] {message}"
Instances
Generic LogRecord Source # 
Instance details

Defined in Logging.Types.Record

Associated Types

type Rep LogRecord :: Type -> Type #

FormatArg LogRecord Source # 
Instance details

Defined in Logging.Types.Record

type Rep LogRecord Source # 
Instance details

Defined in Logging.Types.Record

data StreamHandler Source #

A handler type which writes logging records, appropriately formatted, to a stream.

Instances
Eq StreamHandler Source # 
Instance details

Defined in Logging.Types.Handlers.StreamHandler

Generic StreamHandler Source # 
Instance details

Defined in Logging.Types.Handlers.StreamHandler

Associated Types

type Rep StreamHandler :: Type -> Type #

FromJSON StreamHandler Source # 
Instance details

Defined in Logging.Aeson

Handler StreamHandler Source # 
Instance details

Defined in Logging.Types.Handlers.StreamHandler

type Rep StreamHandler Source # 
Instance details

Defined in Logging.Types.Handlers.StreamHandler

type Rep StreamHandler = D1 (MetaData "StreamHandler" "Logging.Types.Handlers.StreamHandler" "log4hs-0.2.0.0-8oBS6FfNdHb6T6wNw0clPG" False) (C1 (MetaCons "StreamHandler" PrefixI True) ((S1 (MetaSel (Just "level") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Level) :*: S1 (MetaSel (Just "filterer") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Filterer)) :*: (S1 (MetaSel (Just "formatter") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Format1) :*: S1 (MetaSel (Just "stream") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Handle))))

data FileHandler Source #

A handler type which writes logging records, appropriately formatted, to a file.

Instances
Eq FileHandler Source # 
Instance details

Defined in Logging.Types.Handlers.FileHandler

Generic FileHandler Source # 
Instance details

Defined in Logging.Types.Handlers.FileHandler

Associated Types

type Rep FileHandler :: Type -> Type #

Handler FileHandler Source # 
Instance details

Defined in Logging.Types.Handlers.FileHandler

FromJSON (IO FileHandler) Source # 
Instance details

Defined in Logging.Aeson

type Rep FileHandler Source # 
Instance details

Defined in Logging.Types.Handlers.FileHandler

data Sink Source #

Sink represents a single logging channel.

A "logging channel" indicates an area of an application. Exactly how an "area" is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of "input processing" might include sub-areas "read CSV files", "read XLS files" and "read Gnumeric files"). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Haskell module namespace. So in the instance given above, channel names might be Input for the upper level, and Input.Csv, Input.Xls and Input.Gnu for the sub-levels. There is no arbitrary limit to the depth of nesting.

Note: The namespaces are case sensitive.

Constructors

Sink 

Fields

Instances
FromJSON Sink Source # 
Instance details

Defined in Logging.Aeson

Filterable Sink Source # 
Instance details

Defined in Logging.Types.Sink

Methods

filter :: Sink -> LogRecord -> Bool Source #

FromJSON (String -> Map String SomeHandler -> Sink) Source # 
Instance details

Defined in Logging.Aeson

data Manager Source #

There is under normal circumstances just one Manager, which holds the hierarchy of sinks.

Instances
FromJSON (IO Manager) Source # 
Instance details

Defined in Logging.Aeson

class Filterable a where Source #

A class represents a common trait of filtering LogRecords

Methods

filter :: a -> LogRecord -> Bool Source #

Instances
Filterable Filter Source # 
Instance details

Defined in Logging.Types.Filter

Filterable Sink Source # 
Instance details

Defined in Logging.Types.Sink

Methods

filter :: Sink -> LogRecord -> Bool Source #

Filterable a => Filterable [a] Source # 
Instance details

Defined in Logging.Types.Class.Filterable

Methods

filter :: [a] -> LogRecord -> Bool Source #

data SomeHandler where Source #

The SomeHandler type is the root of the handler type hierarchy. It holds the real Handler instance

Constructors

SomeHandler :: Handler h => h -> SomeHandler 
Instances
Eq SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

Handler SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

HasType Format1 SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

HasType Level SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

HasType Filterer SomeHandler Source # 
Instance details

Defined in Logging.Types.Class.Handler

FromJSON (IO SomeHandler) Source # 
Instance details

Defined in Logging.Aeson

FromJSON (Map String Format1 -> IO SomeHandler) Source # 
Instance details

Defined in Logging.Aeson

FromJSON (String -> Map String SomeHandler -> Sink) Source # 
Instance details

Defined in Logging.Aeson

class (HasType Level a, HasType Filterer a, HasType Format1 a, Typeable a, Eq a) => Handler a where Source #

A type class that abstracts the characteristics of a Handler

Note: Locking is not necessary, because Handle has done it on handle operations.

Minimal complete definition

emit

Methods

open :: a -> IO () Source #

emit :: a -> LogRecord -> IO () Source #

close :: a -> IO () Source #

handle :: a -> LogRecord -> IO Bool Source #

fromHandler :: SomeHandler -> Maybe a Source #

toHandler :: a -> SomeHandler Source #