156 lines
5.2 KiB
Java
156 lines
5.2 KiB
Java
package lombok.core.debug;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import org.eclipse.core.runtime.ILog;
|
|
import org.eclipse.core.runtime.Platform;
|
|
import org.eclipse.core.runtime.Status;
|
|
import org.osgi.framework.Bundle;
|
|
/* loaded from: com.discord-119106.apk:lombok/core/debug/ProblemReporter.SCL.lombok */
|
|
public class ProblemReporter {
|
|
private static ErrorLogger logger;
|
|
|
|
/* loaded from: com.discord-119106.apk:lombok/core/debug/ProblemReporter$EclipseWorkspaceLogger.SCL.lombok */
|
|
private static class EclipseWorkspaceLogger implements ErrorLogger {
|
|
private static final int MAX_LOG = 200;
|
|
private static final long SQUELCH_TIMEOUT = TimeUnit.HOURS.toMillis(1);
|
|
private static final AtomicInteger counter = new AtomicInteger();
|
|
private static volatile long squelchTimeout = 0;
|
|
private static final String DEFAULT_BUNDLE_NAME = "org.eclipse.jdt.core";
|
|
private static final Bundle bundle = Platform.getBundle(DEFAULT_BUNDLE_NAME);
|
|
|
|
static {
|
|
if (bundle == null) {
|
|
throw new NoClassDefFoundError();
|
|
}
|
|
}
|
|
|
|
private EclipseWorkspaceLogger() {
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void info(String str, Throwable th) {
|
|
msg(1, str, th);
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void warning(String str, Throwable th) {
|
|
msg(2, str, th);
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void error(String str, Throwable th) {
|
|
msg(4, str, th);
|
|
}
|
|
|
|
private void msg(int i, String str, Throwable th) {
|
|
int incrementAndGet = squelchTimeout != 0 ? 0 : counter.incrementAndGet();
|
|
boolean z2 = false;
|
|
if (squelchTimeout != 0) {
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
if (squelchTimeout <= currentTimeMillis) {
|
|
squelchTimeout = currentTimeMillis + SQUELCH_TIMEOUT;
|
|
z2 = true;
|
|
} else {
|
|
return;
|
|
}
|
|
} else if (incrementAndGet >= 200) {
|
|
squelchTimeout = System.currentTimeMillis() + SQUELCH_TIMEOUT;
|
|
z2 = true;
|
|
}
|
|
ILog log = Platform.getLog(bundle);
|
|
log.log(new Status(i, DEFAULT_BUNDLE_NAME, str, th));
|
|
if (z2) {
|
|
log.log(new Status(2, DEFAULT_BUNDLE_NAME, "Lombok has logged too many messages; to avoid memory issues, further lombok logs will be squelched for a while. Restart eclipse to start over."));
|
|
}
|
|
}
|
|
|
|
/* synthetic */ EclipseWorkspaceLogger(EclipseWorkspaceLogger eclipseWorkspaceLogger) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* loaded from: com.discord-119106.apk:lombok/core/debug/ProblemReporter$ErrorLogger.SCL.lombok */
|
|
private interface ErrorLogger {
|
|
void info(String str, Throwable th);
|
|
|
|
void warning(String str, Throwable th);
|
|
|
|
void error(String str, Throwable th);
|
|
}
|
|
|
|
/* loaded from: com.discord-119106.apk:lombok/core/debug/ProblemReporter$TerminalLogger.SCL.lombok */
|
|
private static class TerminalLogger implements ErrorLogger {
|
|
private TerminalLogger() {
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void info(String str, Throwable th) {
|
|
System.err.println(str);
|
|
if (th != null) {
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void warning(String str, Throwable th) {
|
|
System.err.println(str);
|
|
if (th != null) {
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override // lombok.core.debug.ProblemReporter.ErrorLogger
|
|
public void error(String str, Throwable th) {
|
|
System.err.println(str);
|
|
if (th != null) {
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/* synthetic */ TerminalLogger(TerminalLogger terminalLogger) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public static void info(String str, Throwable th) {
|
|
init();
|
|
try {
|
|
logger.info(str, th);
|
|
} catch (Throwable unused) {
|
|
logger = new TerminalLogger(null);
|
|
logger.info(str, th);
|
|
}
|
|
}
|
|
|
|
public static void warning(String str, Throwable th) {
|
|
init();
|
|
try {
|
|
logger.warning(str, th);
|
|
} catch (Throwable unused) {
|
|
logger = new TerminalLogger(null);
|
|
logger.warning(str, th);
|
|
}
|
|
}
|
|
|
|
public static void error(String str, Throwable th) {
|
|
init();
|
|
try {
|
|
logger.error(str, th);
|
|
} catch (Throwable unused) {
|
|
logger = new TerminalLogger(null);
|
|
logger.error(str, th);
|
|
}
|
|
}
|
|
|
|
private static void init() {
|
|
if (logger == null) {
|
|
try {
|
|
logger = new EclipseWorkspaceLogger(null);
|
|
} catch (Throwable unused) {
|
|
logger = new TerminalLogger(null);
|
|
}
|
|
}
|
|
}
|
|
}
|