df1-0.1.1: Type, render and parse the df1 hierarchical structured log format

Safe HaskellSafe
LanguageHaskell2010

Df1

Contents

Description

This module exports tools for typing, parsing, and rendering logs in the df1 hierarchical structured logging format.

Consider this a preview release: The API is likely to stay stable, but extensive testing, formalization and tooling is due.

Synopsis

Types

data Log #

Constructors

Log 

Fields

Instances
Eq Log # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Log # 
Instance details

Defined in Df1.Types

Methods

showsPrec :: Int -> Log -> ShowS #

show :: Log -> String #

showList :: [Log] -> ShowS #

data Level #

Importance of the logged message.

These levels, listed in increasing order of importance, correspond to the levels used by syslog(3).

Constructors

Debug

Message intended to be useful only when deliberately debugging a program.

Info

Informational message.

Notice

A condition that is not an error, but should possibly be handled specially.

Warning

A warning condition, such as an exception being gracefully handled or some missing configuration setting being assigned a default value.

Error

Error condition, such as an unhandled exception.

Critical

Critical condition that could result in system failure, such as a disk running out of space.

Alert

A condition that should be corrected immediately, such as a corrupted database.

Emergency

System is unusable.

Instances
Bounded Level # 
Instance details

Defined in Df1.Types

Enum Level # 
Instance details

Defined in Df1.Types

Eq Level # 
Instance details

Defined in Df1.Types

Methods

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

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

Ord Level #

Order of importance. For example, Emergency is more important than Debug:

Emergency > Debug  ==  True
Instance details

Defined in Df1.Types

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 #

Show Level # 
Instance details

Defined in Df1.Types

Methods

showsPrec :: Int -> Level -> ShowS #

show :: Level -> String #

showList :: [Level] -> ShowS #

data Path #

Path represents the hierarchical structure of logged messages.

For example, consider a df1 log line as like the following:

1999-12-20T07:11:39.230553031Z foo x=a y=b qux z=c z=d WARNING Something

For that line, the log_path attribute of the Log datatype will contain the following:

[ Push (segment "foo")
, Attr (key "x") (value "a")
, Attr (key "y") (value "b")
, Push (segment "qux")
, Attr (key "z") (value "c")
, Attr (key "z") (value "d")
] :: Seq Path

Please notice that [] :: Seq Path is a valid path insofar as df1 is concerned, and that Attr and Push can be juxtapositioned in any order.

Constructors

Push !Segment 
Attr !Key !Value 
Instances
Eq Path # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Path # 
Instance details

Defined in Df1.Types

Methods

showsPrec :: Int -> Path -> ShowS #

show :: Path -> String #

showList :: [Path] -> ShowS #

data Segment #

A path segment.

If you have the OverloadedStrings GHC extension enabled, you can build a Segment using a string literal:

"foo" :: Segment

Otherwise, you can use fromString or the Segment constructor directly.

Instances
Eq Segment # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Segment # 
Instance details

Defined in Df1.Types

IsString Segment # 
Instance details

Defined in Df1.Types

Methods

fromString :: String -> Segment #

Semigroup Segment # 
Instance details

Defined in Df1.Types

Monoid Segment # 
Instance details

Defined in Df1.Types

data Key #

An attribute key (see Attr).

If you have the OverloadedStrings GHC extension enabled, you can build a Key using a string literal:

"foo" :: Key

Otherwise, you can use fromString or the key function.

Please keep in mind that Key will always strip surrounding whitespace. That is:

"x" :: Key  ==  " x"  == "x " == " x "
Instances
Eq Key # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Key # 
Instance details

Defined in Df1.Types

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

IsString Key # 
Instance details

Defined in Df1.Types

Methods

fromString :: String -> Key #

Semigroup Key # 
Instance details

Defined in Df1.Types

Methods

(<>) :: Key -> Key -> Key #

sconcat :: NonEmpty Key -> Key #

stimes :: Integral b => b -> Key -> Key #

Monoid Key # 
Instance details

Defined in Df1.Types

Methods

mempty :: Key #

mappend :: Key -> Key -> Key #

mconcat :: [Key] -> Key #

unKey :: Key -> Text #

key :: Text -> Key #

data Value #

An attribute value (see Attr).

If you have the OverloadedStrings GHC extension enabled, you can build a Value using a string literal:

"foo" :: Value

Otherwise, you can use fromString or the value function.

Please keep in mind that value will always strip surrounding whitespace. That is:

"x" :: Value  ==  " x"  == "x " == " x "
Instances
Eq Value # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Value # 
Instance details

Defined in Df1.Types

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

IsString Value # 
Instance details

Defined in Df1.Types

Methods

fromString :: String -> Value #

Semigroup Value # 
Instance details

Defined in Df1.Types

Methods

(<>) :: Value -> Value -> Value #

sconcat :: NonEmpty Value -> Value #

stimes :: Integral b => b -> Value -> Value #

Monoid Value # 
Instance details

Defined in Df1.Types

Methods

mempty :: Value #

mappend :: Value -> Value -> Value #

mconcat :: [Value] -> Value #

data Message #

A message text.

If you have the OverloadedStrings GHC extension enabled, you can build a Message using a string literal:

"foo" :: Message

Please keep in mind that Message will always strip surrounding whitespace. That is:

"x" :: Message  ==  " x"  == "x " == " x "
Instances
Eq Message # 
Instance details

Defined in Df1.Types

Methods

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

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

Show Message # 
Instance details

Defined in Df1.Types

IsString Message # 
Instance details

Defined in Df1.Types

Methods

fromString :: String -> Message #

Semigroup Message # 
Instance details

Defined in Df1.Types

Monoid Message # 
Instance details

Defined in Df1.Types

Parsing

parse :: Parser Log #

If sucessful, parsing will stop after the first CR or LF newline marker if any, otherwise it will consume all input.

Rendering

render :: Log -> Builder #

Like renderColor, but without color.