]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.logbot: Small refactoring
authorBruno Deferrari <utizoc@gmail.com>
Sat, 30 May 2009 13:09:44 +0000 (10:09 -0300)
committerBruno Deferrari <utizoc@gmail.com>
Sat, 30 May 2009 13:09:44 +0000 (10:09 -0300)
extra/irc/logbot/logbot.factor

index ff8085a9a9c5dc99a1191916056c346c3c0cf8cb..976a3832f47fdbe0b210bafe651e1c345357f8e1 100644 (file)
@@ -21,15 +21,17 @@ SYMBOL: current-stream
 : timestamp-path ( timestamp -- path )
     timestamp>ymd ".log" append log-directory prepend-path ;
 
+: update-current-stream ( timestamp -- )
+    current-stream get [ dispose ] when*
+    [ day-of-year current-day set ]
+    [ timestamp-path latin1 <file-appender> ] bi
+    current-stream set ;
+
+: same-day? ( timestamp -- ? ) day-of-year current-day get = ;
+
 : timestamp>stream ( timestamp  -- stream )
-    dup day-of-year current-day get = [
-        drop
-    ] [
-        current-stream get [ dispose ] when*
-        [ day-of-year current-day set ]
-        [ timestamp-path latin1 <file-appender> ] bi
-        current-stream set
-    ] if current-stream get ;
+    dup same-day? [ drop ] [ update-current-stream ] if
+    current-stream get ;
 
 : log-message ( string timestamp -- )
     [ add-timestamp ] [ timestamp>stream ] bi