From b010cd311687ed5a462821c00a436efa146426dd Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 30 May 2009 10:09:44 -0300 Subject: [PATCH] irc.logbot: Small refactoring --- extra/irc/logbot/logbot.factor | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/extra/irc/logbot/logbot.factor b/extra/irc/logbot/logbot.factor index ff8085a9a9..976a3832f4 100644 --- a/extra/irc/logbot/logbot.factor +++ b/extra/irc/logbot/logbot.factor @@ -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 ] 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 ] 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 -- 2.34.1