log4hs-0.5.0.0: A python logging style log library

Copyright(c) 2019 Version Cloud
LicenseBSD3
MaintainerJorah Gao <log4hs@version.cloud>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Logging

Description

A python logging style log library.

A simple example:

  {-# LANGUAGE OverloadedStrings #-}
  {-# LANGUAGE TemplateHaskell   #-}

  module Main ( main ) where

  import           Logging             (run)
  import           Logging.Config.Json (getManager)
  import           Logging.TH          (debug, error, fatal, info, logv, warn)
  import           Prelude             hiding (error)

  main :: IO ()
  main = getManager "{}" >>= flip run app

  myLogger = "MyLogger.Main"

  app :: IO ()
  app = do
    $(debug) myLogger "this is a test message"
    $(info) myLogger "this is a test message"
    $(warn) myLogger "this is a test message"
    $(error) myLogger "this is a test message"
    $(fatal) myLogger "this is a test message"
    $(logv) myLogger "LEVEL 100" "this is a test message"

See Logging.Config.Json and Logging.Config.Yaml to lean more about decoding Manager from json or yaml

Synopsis

Documentation

module Logging.TH

run :: Manager -> IO a -> IO a Source #

Run a logging environment.

You should always write you application inside a logging environment.

  1. rename "main" function to "originMain" (or whatever you call it)
  2. write "main" as below
main :: IO ()
main = run manager originMain
...

stderrHandler :: StreamHandler Source #

Deprecated: Will be removed

A StreamHandler bound to stderr

stdoutHandler :: StreamHandler Source #

Deprecated: Will be removed

A StreamHandler bound to stdout

defaultRoot :: Sink Source #

Deprecated: Will be removed

Default root sink which is used by Logging.Config.Json and Logging.Config.Yaml when root sink is omitted.