Search in sources :

Example 6 with JobLogLine

use of org.platformlayer.jobs.model.JobLogLine in project platformlayer by platformlayer.

the class SimpleJobLogger method enterScope.

@Override
public void enterScope(Object controller) {
    String name = ControllerNameStrategy.getName(controller);
    JobLogLine line = new JobLogLine();
    line.type = JobLogLine.TYPE_ENTER_SCOPE;
    line.message = name;
    lines.add(line);
}
Also used : JobLogLine(org.platformlayer.jobs.model.JobLogLine)

Example 7 with JobLogLine

use of org.platformlayer.jobs.model.JobLogLine 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();
}
Also used : JobLogLine(org.platformlayer.jobs.model.JobLogLine) JobLogExceptionInfo(org.platformlayer.jobs.model.JobLogExceptionInfo)

Example 8 with JobLogLine

use of org.platformlayer.jobs.model.JobLogLine 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);
}
Also used : JobLogLine(org.platformlayer.jobs.model.JobLogLine) JobLogExceptionInfo(org.platformlayer.jobs.model.JobLogExceptionInfo)

Example 9 with JobLogLine

use of org.platformlayer.jobs.model.JobLogLine in project platformlayer by platformlayer.

the class JobLogStoreBase method deserialize.

protected JobLog deserialize(InputSupplier<? extends InputStream> iss, int logSkip) throws IOException {
    ArrayList<JobLogLine> lines = Lists.newArrayList();
    InputStream is = null;
    CodedInputStream in = null;
    try {
        is = iss.getInput();
        is = new GZIPInputStream(is);
        in = CodedInputStream.newInstance(is);
        int i = 0;
        JobDataProtobuf.JobLogLine.Builder protobuf = JobDataProtobuf.JobLogLine.newBuilder();
        while (!in.isAtEnd()) {
            int length = in.readRawVarint32();
            if (i < logSkip) {
                in.skipRawBytes(length);
            } else {
                int oldLimit = in.pushLimit(length);
                protobuf.clear();
                protobuf.mergeFrom(in);
                JobLogLine line = new JobLogLine();
                line.level = protobuf.getLevel();
                line.timestamp = protobuf.getTimestamp();
                line.message = protobuf.getMessage();
                line.type = protobuf.getType();
                if (protobuf.hasException()) {
                    line.exception = mapFromProtobuf(protobuf.getExceptionBuilder());
                }
                lines.add(line);
                in.popLimit(oldLimit);
            }
            i++;
        }
    } finally {
        // Closeables.closeQuietly(in);
        Closeables.closeQuietly(is);
    }
    JobLog jobLog = new JobLog();
    jobLog.lines = lines;
    return jobLog;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) JobLogLine(org.platformlayer.jobs.model.JobLogLine) GZIPInputStream(java.util.zip.GZIPInputStream) CodedInputStream(com.google.protobuf.CodedInputStream) InputStream(java.io.InputStream) CodedInputStream(com.google.protobuf.CodedInputStream) JobLog(org.platformlayer.jobs.model.JobLog)

Aggregations

JobLogLine (org.platformlayer.jobs.model.JobLogLine)9 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)2 JobLog (org.platformlayer.jobs.model.JobLog)2 JobLogExceptionInfo (org.platformlayer.jobs.model.JobLogExceptionInfo)2 CodedInputStream (com.google.protobuf.CodedInputStream)1 CodedOutputStream (com.google.protobuf.CodedOutputStream)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)1 JobDataProtobuf (org.platformlayer.ops.jobstore.protobuf.JobDataProtobuf)1