-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathLoggingEvent.java
More file actions
63 lines (50 loc) · 1.57 KB
/
LoggingEvent.java
File metadata and controls
63 lines (50 loc) · 1.57 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.github.stickerifier.stickerify.logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.LoggingEventVO;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.classic.spi.ThrowableProxyVO;
import com.github.stickerifier.stickerify.exception.TelegramApiException;
import org.jspecify.annotations.Nullable;
/**
* Test double that serves as an implementation of {@link ILoggingEvent}.
*/
class LoggingEvent extends LoggingEventVO {
static final String EXCEPTION_CLASS = TelegramApiException.class.getName();
private final String formattedMessage;
private @Nullable IThrowableProxy throwableProxy;
LoggingEvent(String formattedMessage) {
this.formattedMessage = formattedMessage;
}
LoggingEvent(String formattedMessage, String exceptionMessage) {
this.formattedMessage = formattedMessage;
this.throwableProxy = new ThrowableProxy(exceptionMessage);
}
private static class ThrowableProxy extends ThrowableProxyVO {
private final String message;
ThrowableProxy(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message;
}
@Override
public String getClassName() {
return EXCEPTION_CLASS;
}
@Override
public StackTraceElementProxy[] getStackTraceElementProxyArray() {
return new StackTraceElementProxy[] {};
}
}
@Override
public String getFormattedMessage() {
return formattedMessage;
}
@Nullable
@Override
public IThrowableProxy getThrowableProxy() {
return throwableProxy;
}
}