log2json-0.1: Turn log file records into JSON.

Safe HaskellSafe-Inferred

Text.LogFormat

Description

LogFormat is a Haskell module that makes it trivial to parse access log records.

Synopsis

Documentation

type Parser a = Parsec String () aSource

Parser a is a Parsec parser for Strings that parses an a.

data Rule Source

A LogFormat string is made up of literal strings (which must match exactly) and % directives that match a certain pattern and can have an optional modifier string.

Instances

headerParser :: Stream s m Char => Maybe [Char] -> ParsecT s u m (Map [Char] [Char]) -> ParsecT s u m (Map [Char] [Char])Source

keyValueParser :: a -> Parser b -> Parser (Map a b)Source

Take a parser and convert it to parse a Map instead of just a value.

ipParser :: Parser StringSource

Parser for IP addresses

hostnameParser :: Parser StringSource

Parser for hostnames

digits :: Stream s m Char => ParsecT s u m [Char]Source

parserFor :: Rule -> Parser (Map String String)Source

Build a parser for a Rule.

For Keyword Rules:

Take a character that is used to define a field in the LogFormat specification and return a Parser that will parse out a key-value for that field from the input. For example, %U in a LogFormat means the URL path, so a URL path parser is available as

       parserFor (Keyword 'U' Nothing)