提交 db8c92f7 编写于 作者: J Jesse Glick

Merge pull request #586 from HedAurabesh/v1.485_gzip

[FIXED JENKINS-13655] Enable transparent log decompression support (Jenkins v1.485)
......@@ -3,6 +3,8 @@
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc.
*
* Copyright (c) 2012, Martin Schroeder, Intel Mobile Communications GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
......@@ -77,7 +79,7 @@ public class AnnotatedLargeText<T> extends LargeText {
private T context;
public AnnotatedLargeText(File file, Charset charset, boolean completed, T context) {
super(file, charset, completed);
super(file, charset, completed, true);
this.context = context;
}
......
......@@ -4,6 +4,8 @@
* Copyright (c) 2004-2012, Sun Microsystems, Inc., Kohsuke Kawaguchi,
* Daniel Dyer, Red Hat, Inc., Tom Huybrechts, Romain Seguy, Yahoo! Inc.,
* Darek Ostolski, CloudBees, Inc.
*
* Copyright (c) 2012, Martin Schroeder, Intel Mobile Communications GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -1189,7 +1191,16 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* Returns the log file.
*/
public File getLogFile() {
return new File(getRootDir(),"log");
File rawF = new File(getRootDir(), "log");
if (rawF.isFile()) {
return rawF;
}
File gzF = new File(getRootDir(), "log.gz");
if (gzF.isFile()) {
return gzF;
}
//If both fail, return the standard, uncompressed log file
return rawF;
}
/**
......@@ -1202,13 +1213,15 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
*/
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists() ) {
return new FileInputStream(logFile);
}
File compressedLogFile = new File(logFile.getParentFile(), logFile.getName()+ ".gz");
if (compressedLogFile.exists()) {
return new GZIPInputStream(new FileInputStream(compressedLogFile));
if (logFile != null && logFile.exists() ) {
// Checking if a ".gz" file was return
FileInputStream fis = new FileInputStream(logFile);
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
}
return new NullInputStream(0);
......
......@@ -3,6 +3,8 @@ The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Copyright (c) 2012, Martin Schroeder, Intel Mobile Communications GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
......@@ -35,7 +37,7 @@ THE SOFTWARE.
</t:buildCaption>
<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logFile.length()-threshold*1024 : 0}" />
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
<j:choose>
<j:when test="${offset > 0}">
${%skipSome(offset/1024,"consoleFull")}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册