irc.logbot: more strftime
parent
3bbc784fad
commit
a66e79dd2d
|
@ -0,0 +1,10 @@
|
||||||
|
USING: calendar irc.logbot tools.test ;
|
||||||
|
IN: irc.logbot.tests
|
||||||
|
|
||||||
|
{ "[10:20:30] hello" } [
|
||||||
|
"hello" 2016 2 3 10 20 30 instant <timestamp> add-timestamp
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ "resource:logs/irc/concatenative/2016-02-03.log" } [
|
||||||
|
2016 2 3 10 20 30 instant <timestamp> timestamp-path
|
||||||
|
] unit-test
|
|
@ -1,9 +1,9 @@
|
||||||
! Copyright (C) 2009 Bruno Deferrari.
|
! Copyright (C) 2009 Bruno Deferrari.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors calendar calendar.format destructors fry io
|
USING: accessors calendar destructors formatting fry io io.directories
|
||||||
io.directories io.encodings.utf8 io.files io.pathnames
|
io.encodings.utf8 io.files io.pathnames irc.client irc.client.chats
|
||||||
irc.client irc.client.chats irc.logbot.log-line splitting
|
irc.logbot.log-line irc.messages.base kernel namespaces sequences
|
||||||
irc.messages.base kernel make namespaces sequences threads ;
|
splitting threads ;
|
||||||
IN: irc.logbot
|
IN: irc.logbot
|
||||||
|
|
||||||
CONSTANT: bot-channel "#concatenative"
|
CONSTANT: bot-channel "#concatenative"
|
||||||
|
@ -23,7 +23,7 @@ SYMBOL: current-stream
|
||||||
nickserv-password get <irc-profile> ;
|
nickserv-password get <irc-profile> ;
|
||||||
|
|
||||||
: add-timestamp ( string timestamp -- string )
|
: add-timestamp ( string timestamp -- string )
|
||||||
timestamp>hms [ "[" % % "] " % % ] "" make ;
|
"[%H:%M:%S] " strftime prepend ;
|
||||||
|
|
||||||
: make-log-path ( -- path )
|
: make-log-path ( -- path )
|
||||||
ircbot-log-directory get default-log-directory or
|
ircbot-log-directory get default-log-directory or
|
||||||
|
@ -31,7 +31,7 @@ SYMBOL: current-stream
|
||||||
append-path ;
|
append-path ;
|
||||||
|
|
||||||
: timestamp-path ( timestamp -- path )
|
: timestamp-path ( timestamp -- path )
|
||||||
timestamp>ymd ".log" append
|
"%Y-%m-%d.log" strftime
|
||||||
make-log-path dup make-directories
|
make-log-path dup make-directories
|
||||||
prepend-path ;
|
prepend-path ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue