[Fencommits] fenserve: add timestamps to the log

Benja Fallenstein benja.fallenstein at gmail.com
Fri Apr 27 19:00:08 EEST 2007


Fri Apr 27 18:59:56 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * add timestamps to the log
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs	2007-04-27 19:00:08.000000000 +0300
+++ new-fenserve/notetaker/Main.hs	2007-04-27 19:00:08.000000000 +0300
@@ -8,6 +8,7 @@
 import Data.List (isPrefixOf)
 import Data.Maybe (fromMaybe)
 import Text.Printf
+import System.Time
 
 data Line = Line { lineTime :: EpochTime, lineNick :: String, 
                    lineBody :: String } deriving (Eq,Ord,Read,Show,Typeable)
@@ -67,8 +68,12 @@
     lines <- get
     respond $ form nick 
            ++ "Views: <a href='/?nick="++nick++"'>main</a> | <b>log</b><p>"
-           ++ flip concatMap lines 
-                  (\(Line t n l) -> printf "&lt;%s&gt; %s<br>" n l :: String)
+           ++ flip concatMap lines (\(Line t n l) ->
+               printf "%s &lt;%s&gt; %s<br>" (renderTime t) n l :: String)
+               
+renderTime :: EpochTime -> String
+renderTime t0 = printf "%02u:%02u" (ctHour t) (ctMin t)
+    where t = toUTCTime (TOD (fromIntegral t0) 0)
     
 main = stdHTTP [ debugFilter
                , h ["log"] GET $ ok $ \() nick -> renderLog nick




More information about the Fencommits mailing list