Created
August 17, 2013 18:18
-
-
Save Rembane/6258093 to your computer and use it in GitHub Desktop.
A small example that shows logging to file and stderr in Haskell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Log.Logger | |
import System.Log.Handler.Simple | |
import System.Log.Handler (setFormatter) | |
import System.Log.Formatter | |
main = do | |
-- Initialize loggers | |
updateGlobalLogger "main" (setLevel DEBUG) | |
h <- fileHandler "logfile.log" DEBUG >>= \lh -> return $ | |
setFormatter lh (simpleLogFormatter "[$time : $loggername : $prio] $msg") | |
updateGlobalLogger "main" (addHandler h) | |
debugM "main" "RAWR!" | |
warningM "main" "ONG HEST!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://hackage.haskell.org/packages/archive/hslogger/latest/doc/html/System-Log-Logger.html