irc.logbot: Small refactoring

db4
Bruno Deferrari 2009-05-30 10:09:44 -03:00
parent e3a8421f44
commit b010cd3116
1 changed files with 10 additions and 8 deletions

View 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