]> gitweb.factorcode.org Git - factor.git/blob - basis/logging/insomniac/insomniac.factor
factor: trim using lists
[factor.git] / basis / logging / insomniac / insomniac.factor
1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar io.streams.string kernel logging
4 logging.analysis make namespaces smtp timers ;
5 QUALIFIED: io.sockets
6 IN: logging.insomniac
7
8 SYMBOL: insomniac-sender
9 SYMBOL: insomniac-recipients
10
11 : email-subject ( service -- string )
12     [
13         "Log analysis for " % % " on " % io.sockets:host-name %
14     ] "" make ;
15
16 :: (email-log-report) ( service word-names -- )
17     <email>
18         [ service word-names analyze-log-file ] with-string-writer >>body
19         insomniac-recipients get >>to
20         insomniac-sender get >>from
21         service email-subject >>subject
22     send-email ;
23
24 \ (email-log-report) NOTICE add-error-logging
25
26 : email-log-report ( service word-names -- )
27     "logging.insomniac" [ (email-log-report) ] with-logging ;
28
29 : schedule-insomniac ( service word-names -- )
30     [ email-log-report rotate-logs ] 2curry
31     1 days every drop ;