irc.logbot: Small refactoring
parent
e3a8421f44
commit
b010cd3116
|
@ -21,15 +21,17 @@ SYMBOL: current-stream
|
||||||
: timestamp-path ( timestamp -- path )
|
: timestamp-path ( timestamp -- path )
|
||||||
timestamp>ymd ".log" append log-directory prepend-path ;
|
timestamp>ymd ".log" append log-directory prepend-path ;
|
||||||
|
|
||||||
: timestamp>stream ( timestamp -- stream )
|
: update-current-stream ( timestamp -- )
|
||||||
dup day-of-year current-day get = [
|
|
||||||
drop
|
|
||||||
] [
|
|
||||||
current-stream get [ dispose ] when*
|
current-stream get [ dispose ] when*
|
||||||
[ day-of-year current-day set ]
|
[ day-of-year current-day set ]
|
||||||
[ timestamp-path latin1 <file-appender> ] bi
|
[ timestamp-path latin1 <file-appender> ] bi
|
||||||
current-stream set
|
current-stream set ;
|
||||||
] if current-stream get ;
|
|
||||||
|
: same-day? ( timestamp -- ? ) day-of-year current-day get = ;
|
||||||
|
|
||||||
|
: timestamp>stream ( timestamp -- stream )
|
||||||
|
dup same-day? [ drop ] [ update-current-stream ] if
|
||||||
|
current-stream get ;
|
||||||
|
|
||||||
: log-message ( string timestamp -- )
|
: log-message ( string timestamp -- )
|
||||||
[ add-timestamp ] [ timestamp>stream ] bi
|
[ add-timestamp ] [ timestamp>stream ] bi
|
||||||
|
|
Loading…
Reference in New Issue