File: Log.hs

package info (click to toggle)
haskell-ircbot 0.6.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 144 kB
  • sloc: haskell: 881; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# LANGUAGE DeriveDataTypeable #-}
module Network.IRC.Bot.Log where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C
import Data.Data

data LogLevel
    = Debug
    | Normal
    | Important
      deriving (Eq, Ord, Read, Show, Data, Typeable)

type Logger = LogLevel -> ByteString -> IO ()

stdoutLogger :: LogLevel -> Logger
stdoutLogger minLvl msgLvl msg
    | msgLvl >= minLvl = C.putStrLn msg -- assumes ascii, which is wrong(?)
    | otherwise        = return ()

nullLogger :: Logger
nullLogger _ _ = return ()