PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/Angel/Log.hs

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