use of org.platformlayer.jobs.model.JobLogExceptionInfo in project platformlayer by platformlayer.
the class JobLogStoreBase method mapFromProtobuf.
private JobLogExceptionInfo mapFromProtobuf(JobDataProtobuf.JobLogExceptionInfo.Builder exceptionBuilder) {
JobLogExceptionInfo exception = new JobLogExceptionInfo();
exception.info = Lists.newArrayList();
for (String info : exceptionBuilder.getInfoList()) {
exception.info.add(info);
}
if (exceptionBuilder.hasInner()) {
exception.inner = mapFromProtobuf(exceptionBuilder.getInnerBuilder());
}
return exception;
}
use of org.platformlayer.jobs.model.JobLogExceptionInfo in project platformlayer by platformlayer.
the class JobLogPrinter method write.
public void write(JobLogLine line) {
String type = line.getType();
if (!Strings.isNullOrEmpty(type)) {
if (type.equals(JobLogLine.TYPE_ENTER_SCOPE)) {
ansi.println(Color.Default, indent + ">>> " + line.message);
depth++;
indent += " ";
} else if (type.equals(JobLogLine.TYPE_EXIT_SCOPE)) {
depth--;
indent = indent.substring(0, depth * 2);
// ansi.println(indent + "<<< " + line.message);
} else {
ansi.println(Color.Red, indent + "??? " + line.message);
}
return;
}
Ansi.Color color = Ansi.Color.Default;
if (line.level >= JobLogLineLevels.LEVEL_ERROR) {
color = Ansi.Color.Red;
} else if (line.level >= JobLogLineLevels.LEVEL_WARN) {
color = Ansi.Color.Yellow;
} else if (line.level >= JobLogLineLevels.LEVEL_INFO) {
color = Ansi.Color.Green;
} else {
color = Ansi.Color.Blue;
}
ansi.println(color, indent + line.message);
JobLogExceptionInfo exceptionInfo = line.exception;
while (exceptionInfo != null) {
for (String exceptionLine : exceptionInfo.info) {
ansi.println(color, indent + exceptionLine);
}
exceptionInfo = exceptionInfo.inner;
}
}
use of org.platformlayer.jobs.model.JobLogExceptionInfo in project platformlayer by platformlayer.
the class SimpleJobLogger method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (JobLogLine jobLogLine : this.getLogEntries()) {
sb.append(jobLogLine.getMessage());
JobLogExceptionInfo exception = jobLogLine.getException();
if (exception != null) {
List<String> infos = exception.getInfo();
for (int i = 0; i < infos.size(); i++) {
String infoLine = infos.get(i);
if (i != 0) {
sb.append('\n');
}
sb.append(infoLine);
}
}
sb.append("\n");
}
return sb.toString();
}
use of org.platformlayer.jobs.model.JobLogExceptionInfo in project platformlayer by platformlayer.
the class SimpleJobLogger method logMessage.
@Override
public void logMessage(String message, List<String[]> exceptionStacks, int level) {
JobLogExceptionInfo jobLogExceptionInfo = null;
if (exceptionStacks != null) {
jobLogExceptionInfo = JobUtils.buildJobLogExceptionInfo(exceptionStacks);
}
JobLogLine jobLogLine = new JobLogLine(System.currentTimeMillis(), level, message, jobLogExceptionInfo);
lines.add(jobLogLine);
}
use of org.platformlayer.jobs.model.JobLogExceptionInfo in project platformlayer by platformlayer.
the class JobUtils method buildJobLogExceptionInfo.
public static JobLogExceptionInfo buildJobLogExceptionInfo(List<String[]> exceptionStacks) {
if (exceptionStacks == null || exceptionStacks.isEmpty()) {
return null;
}
JobLogExceptionInfo ret = null;
for (String[] exceptionStack : Lists.reverse(exceptionStacks)) {
JobLogExceptionInfo exception = new JobLogExceptionInfo();
exception.getInfo().addAll(Arrays.asList(exceptionStack));
exception.inner = ret;
ret = exception;
}
return ret;
}
Aggregations