use of ch.qos.logback.classic.spi.StackTraceElementProxy in project cdap by caskdata.
the class TwillLogThrowableAdapter method getStackTraceElementProxyArray.
@Override
public StackTraceElementProxy[] getStackTraceElementProxyArray() {
StackTraceElementProxy[] result = new StackTraceElementProxy[throwable.getStackTraces().length];
for (int i = 0; i < throwable.getStackTraces().length; i++) {
StackTraceElement original = throwable.getStackTraces()[i];
result[i] = new StackTraceElementProxy(original);
}
return result;
}
use of ch.qos.logback.classic.spi.StackTraceElementProxy in project cdap by caskdata.
the class StackTraceElementProxyArraySerializer method encode.
static GenericArray<GenericRecord> encode(Schema schema, StackTraceElementProxy[] stackTraceElementProxies) {
if (stackTraceElementProxies != null) {
Schema steArraySchema = schema.getTypes().get(1);
GenericArray<GenericRecord> steArray = new GenericData.Array<>(stackTraceElementProxies.length, steArraySchema);
for (StackTraceElementProxy ste : stackTraceElementProxies) {
steArray.add(StackTraceElementProxySerializer.encode(steArraySchema.getElementType(), ste));
}
return steArray;
}
return null;
}
use of ch.qos.logback.classic.spi.StackTraceElementProxy in project cdap by caskdata.
the class ThrowableProxySerializer method decode.
static IThrowableProxy decode(GenericRecord datum) {
if (datum != null) {
String className = LoggingUtil.stringOrNull(datum.get("className"));
String message = LoggingUtil.stringOrNull(datum.get("message"));
int commonFramesCount = (Integer) datum.get("commonFramesCount");
@SuppressWarnings("unchecked") StackTraceElementProxy[] steArray = StackTraceElementProxyArraySerializer.decode((GenericArray<GenericRecord>) datum.get("stackTraceElementProxyArray"));
IThrowableProxy cause = ThrowableProxySerializer.decode((GenericRecord) datum.get("cause"));
@SuppressWarnings("unchecked") IThrowableProxy[] suppressed = ThrowableProxyArraySerializer.decode((GenericArray<GenericRecord>) datum.get("suppressed"));
return new ThrowableProxyImpl(cause, className, commonFramesCount, message, steArray, suppressed);
}
return null;
}
use of ch.qos.logback.classic.spi.StackTraceElementProxy in project platformlayer by platformlayer.
the class LogbackHook method append.
@Override
protected void append(E e) {
OpsContext opsContext = OpsContext.get();
if (opsContext != null) {
ILoggingEvent event = (ILoggingEvent) e;
// Note that we can get the unformatted message in getMessage(), presumably along with the parameters...
String message = event.getFormattedMessage();
Level level = event.getLevel();
int levelInt = level.toInt();
List<String[]> exceptionStacks = null;
IThrowableProxy throwableInformation = event.getThrowableProxy();
while (throwableInformation != null) {
String[] exceptionStackTrace = null;
StackTraceElementProxy[] trace = throwableInformation.getStackTraceElementProxyArray();
String exceptionMessage = throwableInformation.getMessage();
String exceptionClass = throwableInformation.getClassName();
if (trace != null) {
exceptionStackTrace = new String[1 + trace.length];
exceptionStackTrace[0] = exceptionClass + ": " + exceptionMessage;
for (int i = 0; i < trace.length; i++) {
exceptionStackTrace[1 + i] = trace[i].getSTEAsString();
}
} else {
exceptionStackTrace = new String[1];
exceptionStackTrace[0] = exceptionClass + ": " + exceptionMessage;
}
if (exceptionStacks == null) {
exceptionStacks = Lists.newArrayList();
}
exceptionStacks.add(exceptionStackTrace);
throwableInformation = throwableInformation.getCause();
}
if (message != null || exceptionStacks != null) {
opsContext.getJobLogger().logMessage(message, exceptionStacks, levelInt);
if (levelInt >= Level.ERROR_INT) {
// String key = "warn-" + OpsSystem.buildSimpleTimeString() + "-" + (System.nanoTime() % 1000);
if (opsContext != null) {
// && opsContext.getOperation() != null) {
if (exceptionStacks != null && !exceptionStacks.isEmpty()) {
String[] exceptionStack = exceptionStacks.get(0);
if (exceptionStack != null && exceptionStack.length > 0) {
message += "; " + exceptionStack[0];
}
}
opsContext.addWarning(null, message);
}
}
}
}
}
use of ch.qos.logback.classic.spi.StackTraceElementProxy in project cdap by caskdata.
the class StackTraceElementProxyArraySerializer method decode.
static StackTraceElementProxy[] decode(GenericArray<GenericRecord> datum) {
if (datum != null) {
StackTraceElementProxy[] stackTraceElementProxies = new StackTraceElementProxy[datum.size()];
int i = 0;
for (GenericRecord aDatum : datum) {
stackTraceElementProxies[i++] = StackTraceElementProxySerializer.decode(aDatum);
}
return stackTraceElementProxies;
}
return null;
}
Aggregations