1 package com.nilhcem.fakesmtp.log;
2
3 import java.util.Observable;
4
5 import ch.qos.logback.classic.spi.ILoggingEvent;
6 import ch.qos.logback.core.AppenderBase;
7
8
9
10
11
12
13
14
15 public final class SMTPLogsAppender<E> extends AppenderBase<E> {
16 private SMTPLogsObservable observable = new SMTPLogsObservable();
17
18
19
20
21
22
23 @Override
24 protected void append(E event) {
25 if (event instanceof ILoggingEvent) {
26 ILoggingEvent loggingEvent = (ILoggingEvent) event;
27 observable.notifyObservers(loggingEvent.getFormattedMessage());
28 }
29 }
30
31
32
33
34
35
36 public Observable getObservable() {
37 return observable;
38 }
39 }