PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Angel/Log.hs

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