Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Logger = String
- newtype Level = Level Int
- data LogRecord = LogRecord {}
- newtype Filter = Filter Logger
- type Filterer = [Filter]
- data Formatter = Formatter {}
- data SomeHandler where
- SomeHandler :: Handler h => h -> SomeHandler
- data StreamHandler = StreamHandler {}
- data Sink = Sink {}
- data Manager = Manager {}
- class Filterable a where
- class Formattable a where
- class (HasType Level a, HasType Filterer a, HasType Formatter a, HasType Lock a, Typeable a) => Handler a where
Documentation
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
Instances
Enum Level Source # | |
Eq Level Source # | |
Ord Level Source # | |
Read Level Source # | |
Show Level Source # | |
IsString Level Source # | |
Defined in Logging.Types fromString :: String -> Level # | |
FromJSON Level Source # | |
Default Level Source # | |
Defined in Logging.Types | |
HasType Level SomeHandler Source # | |
Defined in Logging.Types typed :: Lens SomeHandler SomeHandler Level Level # getTyped :: SomeHandler -> Level # setTyped :: Level -> SomeHandler -> SomeHandler # |
A LogRecord
represents an event being logged.
LogRecord
s 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.
Filter
s are used to perform arbitrary filtering of LogRecord
s.
Sink
s and Handler
s 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.
Instances
Eq Filter Source # | |
Read Filter Source # | |
Show Filter Source # | |
IsString Filter Source # | |
Defined in Logging.Types fromString :: String -> Filter # | |
FromJSON Filter Source # | |
Filterable Filter Source # | |
HasType Filterer SomeHandler Source # | |
Defined in Logging.Types typed :: Lens SomeHandler SomeHandler Filterer Filterer # getTyped :: SomeHandler -> Filterer # setTyped :: Filterer -> SomeHandler -> SomeHandler # |
Formatter
s are used to convert a LogRecord to text.
Formatter
s need to know how a LogRecord
is constructed. They are
responsible for converting a LogRecord
to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the
default value, "%(message)s" is used.
The Formatter
can be initialized with a format string which makes use of
knowledge of the LogRecord
attributes - e.g. the default value mentioned
above makes use of a LogRecord'
s message attribute. Currently, the useful
attributes in a LogRecord
are described by:
%(logger)s
- Name of the logger (logging channel)
%(level)s
- Numeric logging level for the message (DEBUG, INFO, WARN, ERROR, FATAL, LEVEL v)
%(pathname)s
- Full pathname of the source file where the logging call was issued (if available)
%(filename)s
- Filename portion of pathname
%(module)s
- Module (name portion of filename)
%(lineno)d
- Source line number where the logging call was issued (if available)
%(created)f
- Time when the LogRecord was created (picoseconds since '1970-01-01 00:00:00')
%(asctime)s
- Textual time when the
LogRecord
was created %(msecs)d
- Millisecond portion of the creation time
%(message)s
- The main message passed to
logv
debug
info
..
Instances
Eq Formatter Source # | |
FromJSON Formatter Source # | |
Default Formatter Source # | |
Defined in Logging.Types | |
Formattable Formatter Source # | |
HasType Formatter SomeHandler Source # | |
Defined in Logging.Types typed :: Lens SomeHandler SomeHandler Formatter Formatter # getTyped :: SomeHandler -> Formatter # setTyped :: Formatter -> SomeHandler -> SomeHandler # | |
FromJSON (Map String Formatter -> IO SomeHandler) Source # | |
Defined in Logging.Aeson |
data SomeHandler where Source #
The SomeHandler
type is the root of the handler type hierarchy.
It hold the real Handler
instance
SomeHandler :: Handler h => h -> SomeHandler |
Instances
data StreamHandler Source #
A handler type which writes logging records, appropriately formatted, to a stream.
Note that this class does not close the stream when the stream is a
terminal device, e.g. stderr
and stdout
.
Note: FileHandler
is an alias of StreamHandler
Instances
Generic StreamHandler Source # | |
Defined in Logging.Types type Rep StreamHandler :: Type -> Type # from :: StreamHandler -> Rep StreamHandler x # to :: Rep StreamHandler x -> StreamHandler # | |
Handler StreamHandler Source # | |
Defined in Logging.Types emit :: StreamHandler -> LogRecord -> IO () Source # flush :: StreamHandler -> IO () Source # close :: StreamHandler -> IO () Source # handle :: StreamHandler -> LogRecord -> IO Bool Source # fromHandler :: SomeHandler -> Maybe StreamHandler Source # toHandler :: StreamHandler -> SomeHandler Source # | |
FromJSON (IO StreamHandler) Source # | |
Defined in Logging.Aeson parseJSON :: Value -> Parser (IO StreamHandler) # parseJSONList :: Value -> Parser [IO StreamHandler] # | |
type Rep StreamHandler Source # | |
Defined in Logging.Types |
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.
There is under normal circumstances just one Manager, which holds the hierarchy of sinks.
class Filterable a where Source #
A class represents a common trait of filtering LogRecord
s
Instances
Filterable Sink Source # | |
Filterable Filter Source # | |
Filterable a => Filterable [a] Source # | |
class Formattable a where Source #
class (HasType Level a, HasType Filterer a, HasType Formatter a, HasType Lock a, Typeable a) => Handler a where Source #
A type class that abstracts the characteristics of a Handler
emit :: a -> LogRecord -> IO () Source #
handle :: a -> LogRecord -> IO Bool Source #
fromHandler :: SomeHandler -> Maybe a Source #
toHandler :: a -> SomeHandler Source #
Instances
Handler StreamHandler Source # | |
Defined in Logging.Types emit :: StreamHandler -> LogRecord -> IO () Source # flush :: StreamHandler -> IO () Source # close :: StreamHandler -> IO () Source # handle :: StreamHandler -> LogRecord -> IO Bool Source # fromHandler :: SomeHandler -> Maybe StreamHandler Source # toHandler :: StreamHandler -> SomeHandler Source # | |
Handler SomeHandler Source # | |
Defined in Logging.Types emit :: SomeHandler -> LogRecord -> IO () Source # flush :: SomeHandler -> IO () Source # close :: SomeHandler -> IO () Source # handle :: SomeHandler -> LogRecord -> IO Bool Source # fromHandler :: SomeHandler -> Maybe SomeHandler Source # toHandler :: SomeHandler -> SomeHandler Source # |