2010-04-11 21:42:12 -04:00
|
|
|
! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
|
2008-09-16 00:20:33 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2010-09-04 19:26:32 -04:00
|
|
|
USING: kernel namespaces accessors combinators make smtp
|
|
|
|
debugger prettyprint sequences io io.streams.string
|
|
|
|
io.encodings.utf8 io.files io.sockets fry continuations
|
|
|
|
mason.common mason.platform mason.config ;
|
2008-09-16 00:20:33 -04:00
|
|
|
IN: mason.email
|
|
|
|
|
2010-04-11 21:42:12 -04:00
|
|
|
: mason-email ( body content-type subject -- )
|
2010-09-04 19:26:32 -04:00
|
|
|
'[
|
|
|
|
<email>
|
|
|
|
builder-from get >>from
|
|
|
|
builder-recipients get >>to
|
|
|
|
_ >>body
|
|
|
|
_ >>content-type
|
|
|
|
_ >>subject
|
|
|
|
send-email
|
|
|
|
] [
|
|
|
|
"E-MAILING FAILED:" print
|
|
|
|
error. flush
|
|
|
|
] recover ;
|
2008-09-16 00:20:33 -04:00
|
|
|
|
2010-04-11 21:42:12 -04:00
|
|
|
: subject-prefix ( -- string )
|
|
|
|
"mason on " platform ": " 3append ;
|
|
|
|
|
|
|
|
: report-subject ( status -- string )
|
|
|
|
[
|
|
|
|
subject-prefix %
|
|
|
|
current-git-id get 7 short head %
|
|
|
|
" -- " %
|
|
|
|
{
|
|
|
|
{ status-clean [ "clean" ] }
|
|
|
|
{ status-dirty [ "dirty" ] }
|
|
|
|
{ status-error [ "error" ] }
|
|
|
|
} case %
|
|
|
|
] "" make ;
|
2008-09-16 00:20:33 -04:00
|
|
|
|
2009-04-17 21:59:59 -04:00
|
|
|
: email-report ( report status -- )
|
2010-04-11 21:42:12 -04:00
|
|
|
[ "text/html" ] dip report-subject mason-email ;
|
2008-09-16 00:20:33 -04:00
|
|
|
|
|
|
|
: email-error ( error callstack -- )
|
|
|
|
[
|
|
|
|
"Fatal error on " write host-name print nl
|
|
|
|
[ error. ] [ callstack. ] bi*
|
2010-04-11 21:42:12 -04:00
|
|
|
] with-string-writer
|
|
|
|
"text/plain"
|
|
|
|
subject-prefix "fatal error" append
|
|
|
|
mason-email ;
|