-
Notifications
You must be signed in to change notification settings - Fork 5
/
Demo.java
34 lines (26 loc) · 1.17 KB
/
Demo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import com.ft.membership.logging.Operation;
import java.util.UUID;
import static com.ft.membership.logging.Operation.operation;
import static com.ft.membership.logging.Operation.resultOperation;
public class Demo {
public static void main(String[] args) {
new Demo().run();
}
protected void run() {
// report starting conditions
final Operation operation = operation("operation").with("argument", UUID.randomUUID()).started(this);
//result operation does not print out the starting conditions, only success/failures
final Operation resultOperation = resultOperation("resultOperation").with("argument", UUID.randomUUID()).started(this);
try {
// do some things
int x = 1/0;
// report success
operation.wasSuccessful().yielding("result","{\"text\": \"hello world\"}").log();
resultOperation.wasSuccessful().yielding("result","{\"text\": \"hello world\"}").log();
} catch(Exception e) {
// report failure
operation.wasFailure().throwingException(e).log();
resultOperation.wasFailure().throwingException(e).log();
}
}
}