| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Logging.Aeson
Contents
Synopsis
Aeson Instances
By using Aeson, we can decode json string into Manager.
A basic Manager json format:
{
"loggers": {"root": {}, "MyLogger": {}},
"handlers": {"console": {}, "file": {}},
"formatters": {"default": {}, "simple": {}}
}
In practice, a set of handlers share a formatter, and other handlers share another one, so we define all the formatters in a map, handler refernces the formatter throught its key.
So as handlers, sinks may share same handlers.
Examples of Formatter json
-- a standard format
{
"fmt": "%(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S"
}
-- missing field will use default value
{
"fmt": "%(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S"
}
-- it works as well, just a string
"%(message)s"
Examples of Handler json
Note: Besides some common field, handler's other fields depend on its type.
-- a standard format
{
"type": "StreamHandler",
"stream": "stderr",
"level": "DEBUG",
"filterer": ["Package.Module.Submodule"],
"formatter": "default",
}
-- FileHandler is just a StreamHandler, the stream is created by openFile
{
"type": "FileHandler",
"file": "./default.log",
"level": "INFO",
"filterer": [],
"formatter": "simple",
}
Orphan instances
| FromJSON Sink Source # | |
| FromJSON Formatter Source # | |
| FromJSON Filter Source # | |
| FromJSON Level Source # | |
| FromJSON (IO Manager) Source # | |
| FromJSON (IO HandlerT) Source # | |
| FromJSON (IO StreamHandler) Source # | |
Methods parseJSON :: Value -> Parser (IO StreamHandler) # parseJSONList :: Value -> Parser [IO StreamHandler] # | |
| FromJSON (Map String Formatter -> IO HandlerT) Source # | |
| FromJSON (String -> Map String HandlerT -> Sink) Source # | |