]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.logbot: more strftime
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 4 Jan 2017 08:46:17 +0000 (09:46 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 4 Jan 2017 08:46:17 +0000 (09:46 +0100)
extra/irc/logbot/logbot-tests.factor [new file with mode: 0644]
extra/irc/logbot/logbot.factor

diff --git a/extra/irc/logbot/logbot-tests.factor b/extra/irc/logbot/logbot-tests.factor
new file mode 100644 (file)
index 0000000..dc2c4f6
--- /dev/null
@@ -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
index 069a54524cbfcb053475b080f99ae2c1eeb28e7b..2732b251a0a0daf77dde29d401f110c0635e9c46 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2009 Bruno Deferrari.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors calendar calendar.format destructors fry io
-io.directories io.encodings.utf8 io.files io.pathnames
-irc.client irc.client.chats irc.logbot.log-line splitting
-irc.messages.base kernel make namespaces sequences threads ;
+USING: accessors calendar destructors formatting fry io io.directories
+io.encodings.utf8 io.files io.pathnames irc.client irc.client.chats
+irc.logbot.log-line irc.messages.base kernel namespaces sequences
+splitting threads ;
 IN: irc.logbot
 
 CONSTANT: bot-channel "#concatenative"
@@ -23,7 +23,7 @@ SYMBOL: current-stream
     nickserv-password get <irc-profile> ;
 
 : add-timestamp ( string timestamp -- string )
-    timestamp>hms [ "[" % % "] " % % ] "" make ;
+    "[%H:%M:%S] " strftime prepend ;
 
 : make-log-path ( -- path )
     ircbot-log-directory get default-log-directory or
@@ -31,7 +31,7 @@ SYMBOL: current-stream
     append-path ;
 
 : timestamp-path ( timestamp -- path )
-    timestamp>ymd ".log" append
+    "%Y-%m-%d.log" strftime
     make-log-path dup make-directories
     prepend-path ;