factor/basis/logging/insomniac/insomniac.factor

33 lines
1.0 KiB
Factor
Raw Normal View History

! Copyright (C) 2008, 2010 Slava Pestov.
2008-02-07 18:07:43 -05:00
! See http://factorcode.org/license.txt for BSD license.
2008-03-07 18:20:15 -05:00
USING: logging.analysis logging.server logging smtp kernel
2010-06-10 17:39:13 -04:00
io.files io.streams.string namespaces make timers assocs
2010-10-02 21:18:54 -04:00
io.encodings.utf8 accessors calendar sequences locals ;
2008-03-07 18:20:15 -05:00
QUALIFIED: io.sockets
2008-02-07 18:07:43 -05:00
IN: logging.insomniac
SYMBOL: insomniac-sender
SYMBOL: insomniac-recipients
: email-subject ( service -- string )
2008-03-07 18:20:15 -05:00
[
"Log analysis for " % % " on " % io.sockets:host-name %
2008-03-07 18:20:15 -05:00
] "" make ;
2008-02-07 18:07:43 -05:00
2010-10-02 21:18:54 -04:00
:: (email-log-report) ( service word-names -- )
<email>
[ service word-names analyze-log-file ] with-string-writer >>body
insomniac-recipients get >>to
insomniac-sender get >>from
service email-subject >>subject
send-email ;
2008-02-07 18:07:43 -05:00
2008-02-07 20:51:37 -05:00
\ (email-log-report) NOTICE add-error-logging
2008-02-07 18:07:43 -05:00
2008-02-07 20:51:37 -05:00
: email-log-report ( service word-names -- )
"logging.insomniac" [ (email-log-report) ] with-logging ;
2008-02-07 18:07:43 -05:00
2008-02-10 02:39:37 -05:00
: schedule-insomniac ( service word-names -- )
[ email-log-report rotate-logs ] 2curry
1 days every drop ;