]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/logging/server/server.factor
factor: trim using lists
[factor.git] / basis / logging / server / server.factor
index 770d3011b9e11fa54c68fbd58c5ea709e9cd4e37..7326ea4b7ca4f301ddb5a0c65064bb9991a999ea 100644 (file)
@@ -3,8 +3,7 @@
 USING: assocs calendar calendar.format combinators
 concurrency.messaging continuations debugger destructors init io
 io.directories io.encodings.utf8 io.files io.pathnames kernel
-locals math math.parser math.ranges namespaces sequences
-strings threads ;
+math math.parser ranges namespaces sequences strings threads ;
 IN: logging.server
 
 : log-root ( -- string )
@@ -36,7 +35,7 @@ SYMBOL: log-files
     finally ; inline
 
 : timestamp-header. ( -- )
-    "[" write now write-timestamp "] " write ;
+    "[" write now write-rfc3339 "] " write ;
 
 : multiline-header ( -- str ) 20 CHAR: - <string> ; foldable
 
@@ -68,14 +67,11 @@ SYMBOL: log-files
 
 CONSTANT: keep-logs 10
 
-: ?delete-file ( path -- )
-    dup exists? [ delete-file ] [ drop ] if ;
-
 : delete-oldest ( service -- )
     keep-logs log# ?delete-file ;
 
 : ?move-file ( old new -- )
-    over exists? [ move-file ] [ 2drop ] if ;
+    over file-exists? [ move-file ] [ 2drop ] if ;
 
 : advance-log ( path n -- )
     [ 1 - log# ] 2keep log# ?move-file ;
@@ -85,7 +81,7 @@ CONSTANT: keep-logs 10
     [
         log-path
         [ delete-oldest ]
-        [ keep-logs 1 [a,b] [ advance-log ] with each ] bi
+        [ keep-logs 1 [a..b] [ advance-log ] with each ] bi
     ] bi ;
 
 : (rotate-logs) ( -- )
@@ -101,7 +97,7 @@ CONSTANT: keep-logs 10
 
 : log-server ( -- )
     [
-        init-namespaces
+        init-namestack
         [ log-server-loop ]
         [ error. (close-logs) ]
         recover t