/Angel/Log.hs
http://github.com/jamwt/Angel · Haskell · 17 lines · 11 code · 3 blank · 3 comment · 0 complexity · e449b9b96b76922daccb70c056850fea MD5 · raw file
- module Angel.Log where
- import Text.Printf (printf)
- import System.Time (getClockTime, toCalendarTime, CalendarTime(..), formatCalendarTime)
- import System.Locale (defaultTimeLocale)
- -- |provide a clean, ISO-ish format for timestamps in logs
- cleanCalendar :: CalendarTime -> String
- cleanCalendar ct = formatCalendarTime defaultTimeLocale "%Y/%m/%d %H:%M:%S" ct
- -- |log a line to stdout; indented for use with partial application for
- -- |"local log"-type macroing
- logger :: String -> String -> IO ()
- logger lname msg = do
- tm <- getClockTime
- ct <- toCalendarTime tm
- printf "[%s] {%s} %s\n" (cleanCalendar ct) lname msg