forked from dtinit/data-transfer-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EncryptingLayout.java
36 lines (29 loc) · 980 Bytes
/
EncryptingLayout.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
35
36
package org.datatransferproject.transfer.logging;
import com.google.common.base.Preconditions;
import java.util.UUID;
import org.apache.log4j.Layout;
import org.apache.log4j.helpers.ISO8601DateFormat;
import org.apache.log4j.spi.LoggingEvent;
public class EncryptingLayout extends Layout {
static UUID jobId;
public static void setJobId(UUID inputJobId) {
Preconditions.checkState(jobId == null, "jobId has already been set");
jobId = inputJobId;
}
@Override
public String format(LoggingEvent event) {
// TODO: read formatting from a config file
return String.format("[%s] [%s]: %s - %s%s",
new ISO8601DateFormat().format(event.timeStamp),
jobId != null ? Long.toHexString(jobId.getMostSignificantBits()) : "undefined",
event.getLevel().toString(),
event.getRenderedMessage(), LINE_SEP);
}
@Override
public boolean ignoresThrowable() {
return true;
}
@Override
public void activateOptions() {
}
}