1 ! Copyright (C) 2008 Slava Pestov.
\r
2 ! See http://factorcode.org/license.txt for BSD license.
\r
3 USING: logging.analysis logging.server logging smtp kernel
\r
4 io.files io.streams.string namespaces make alarms assocs
\r
5 io.encodings.utf8 accessors calendar sequences ;
\r
6 QUALIFIED: io.sockets
\r
7 IN: logging.insomniac
\r
9 SYMBOL: insomniac-sender
\r
10 SYMBOL: insomniac-recipients
\r
12 : ?analyze-log ( service word-names -- string/f )
\r
13 [ analyze-log-file ] with-string-writer ;
\r
15 : email-subject ( service -- string )
\r
17 "[INSOMNIAC] " % % " on " % io.sockets:host-name %
\r
20 : (email-log-report) ( service word-names -- )
\r
21 dupd ?analyze-log [ drop ] [
\r
24 insomniac-recipients get >>to
\r
25 insomniac-sender get >>from
\r
26 swap email-subject >>subject
\r
30 \ (email-log-report) NOTICE add-error-logging
\r
32 : email-log-report ( service word-names -- )
\r
33 "logging.insomniac" [ (email-log-report) ] with-logging ;
\r
35 : schedule-insomniac ( service word-names -- )
\r
36 [ [ email-log-report ] assoc-each rotate-logs ] 2curry
\r