2008-02-07 18:07:43 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Copyright (C) 2008 Slava Pestov.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! 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
							 | 
						
					
						
							
								
									
										
										
										
											2008-09-10 23:11:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								io.files io.streams.string namespaces make alarms assocs
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-17 19:10:01 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								io.encodings.utf8 accessors calendar sequences ;
							 | 
						
					
						
							
								
									
										
										
										
											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
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-07 20:51:37 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: ?analyze-log ( service word-names -- string/f )
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-09 17:34:05 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ analyze-log-file ] with-string-writer ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-07 18:07:43 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: email-subject ( service -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-07 18:20:15 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "[INSOMNIAC] " % % " on " % io.sockets:host-name %
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] "" make ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-07 18:07:43 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: (email-log-report) ( service word-names -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-09-06 20:13:59 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dupd ?analyze-log [ drop ] [
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-11 04:35:43 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        <email>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            swap >>body
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            insomniac-recipients get >>to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            insomniac-sender get >>from
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            swap email-subject >>subject
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        send-email
							 | 
						
					
						
							
								
									
										
										
										
											2008-09-06 20:13:59 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] if-empty ;
							 | 
						
					
						
							
								
									
										
										
										
											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 -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-07 17:59:44 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ [ email-log-report ] assoc-each rotate-logs ] 2curry
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    1 days every drop ;
							 |