log4hs-0.0.6.0: A python logging style log library

Safe HaskellNone
LanguageHaskell2010

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": {}},
        "disabled": false,
        "catchUncaughtException": true
      }
    

    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",
      }
    

    Examples of Logger (Sink) json

      -- a standard format
      {
        "level": "DEBUG",
        "filterer": ["Package.Module.Submodule"],
        "handlers": ["console"],
        "propagate": true,
        "disabled": false
      }
    
      -- this example is equivalent to the first
      {
        "level": "DEBUG",
        "filterer": ["Package.Module.Submodule"],
        "handlers": ["console"]
      }
    
      -- another example
      {
        "level": "INFO",
        "handlers": ["console", "file"],
        "propagate": false
      }
    

    Orphan instances