1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: logging.analysis logging.server logging smtp kernel
4 io.files io.streams.string namespaces make timers assocs
5 io.encodings.utf8 accessors calendar sequences locals ;
9 SYMBOL: insomniac-sender
10 SYMBOL: insomniac-recipients
12 : email-subject ( service -- string )
14 "Log analysis for " % % " on " % io.sockets:host-name %
17 :: (email-log-report) ( service word-names -- )
19 [ service word-names analyze-log-file ] with-string-writer >>body
20 insomniac-recipients get >>to
21 insomniac-sender get >>from
22 service email-subject >>subject
25 \ (email-log-report) NOTICE add-error-logging
27 : email-log-report ( service word-names -- )
28 "logging.insomniac" [ (email-log-report) ] with-logging ;
30 : schedule-insomniac ( service word-names -- )
31 [ email-log-report rotate-logs ] 2curry