ReplicationLogImpl.java
3.63 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.replication.impl;
import com.day.cq.replication.Agent;
import com.day.cq.replication.ReplicationLog;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReplicationLogImpl
implements ReplicationLog {
private final Logger logger;
private ReplicationLog.Level level;
private final String category;
private int maxLines = 8192;
private final LinkedList<String> lines = new LinkedList();
public ReplicationLogImpl(String category, ReplicationLog.Level logLevel) {
this.category = category;
this.level = logLevel;
this.logger = LoggerFactory.getLogger((String)(Agent.class.getName() + "." + category));
}
@Override
public ReplicationLog.Level getLevel() {
return this.level;
}
@Override
public void setLevel(ReplicationLog.Level level) {
this.level = level;
}
public void setLevel(String level) {
try {
this.level = ReplicationLog.Level.valueOf(level.toUpperCase());
}
catch (IllegalArgumentException var2_2) {
// empty catch block
}
}
public int getMaxLines() {
return this.maxLines;
}
public void setMaxLines(int maxLines) {
this.maxLines = maxLines;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void log(ReplicationLog.Level level, String message) {
if (level.cardinal < this.level.cardinal) {
return;
}
StringBuffer log = new StringBuffer();
log.append(System.currentTimeMillis());
log.append(" - ");
log.append(level.name());
log.append(" - ");
log.append(this.category);
log.append(" : ");
log.append(message);
LinkedList<String> linkedList = this.lines;
synchronized (linkedList) {
this.lines.add(log.toString());
while (this.lines.size() > this.maxLines) {
this.lines.removeFirst();
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public Collection<String> getLines() {
LinkedList<String> linkedList = this.lines;
synchronized (linkedList) {
return new ArrayList<String>(this.lines);
}
}
@Override
public void debug(String message) {
this.logger.debug(message);
this.log(ReplicationLog.Level.DEBUG, message);
}
@Override
public /* varargs */ void debug(String fmt, Object ... args) {
this.debug(String.format(fmt, args));
}
@Override
public void info(String message) {
this.logger.info(message);
this.log(ReplicationLog.Level.INFO, message);
}
@Override
public /* varargs */ void info(String fmt, Object ... args) {
this.info(String.format(fmt, args));
}
@Override
public void warn(String message) {
this.logger.warn(message);
this.log(ReplicationLog.Level.WARN, message);
}
@Override
public /* varargs */ void warn(String fmt, Object ... args) {
this.warn(String.format(fmt, args));
}
@Override
public void error(String message) {
this.logger.error(message);
this.log(ReplicationLog.Level.ERROR, message);
}
@Override
public /* varargs */ void error(String fmt, Object ... args) {
this.error(String.format(fmt, args));
}
}