-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve recently added log messages by adding context to indicate which build is relevant #640
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,6 @@ | |
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.xml.stream.XMLStreamException; | ||
import javax.xml.stream.XMLStreamReader; | ||
|
@@ -269,7 +268,7 @@ public static float clampDuration(float d) { | |
return Math.min(365.0f * 24 * 60 * 60, Math.max(0.0f, d)); | ||
} | ||
|
||
public static CaseResult parse(SuiteResult parent, final XMLStreamReader reader, String ver) | ||
static CaseResult parse(SuiteResult parent, final XMLStreamReader reader, String context, String ver) | ||
throws XMLStreamException { | ||
CaseResult r = new CaseResult(parent, null, null, null); | ||
while (reader.hasNext()) { | ||
|
@@ -318,19 +317,17 @@ public static CaseResult parse(SuiteResult parent, final XMLStreamReader reader, | |
break; | ||
case "properties": | ||
r.properties = new HashMap<>(); | ||
parseProperties(r.properties, reader, ver); | ||
parseProperties(r.properties, reader, context, ver); | ||
break; | ||
default: | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
LOGGER.finest("CaseResult.parse encountered an unknown field: " + elementName); | ||
} | ||
LOGGER.finest(() -> "Unknown field in " + context + ": " + elementName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also checked whether |
||
} | ||
} | ||
} | ||
return r; | ||
} | ||
|
||
public static void parseProperties(Map<String, String> r, final XMLStreamReader reader, String ver) | ||
static void parseProperties(Map<String, String> r, final XMLStreamReader reader, String context, String ver) | ||
throws XMLStreamException { | ||
while (reader.hasNext()) { | ||
final int event = reader.next(); | ||
|
@@ -341,18 +338,16 @@ public static void parseProperties(Map<String, String> r, final XMLStreamReader | |
final String elementName = reader.getLocalName(); | ||
switch (elementName) { | ||
case "entry": | ||
parseProperty(r, reader, ver); | ||
parseProperty(r, reader, context, ver); | ||
break; | ||
default: | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
LOGGER.finest("CaseResult.parseProperties encountered an unknown field: " + elementName); | ||
} | ||
LOGGER.finest(() -> "Unknown field in " + context + ": " + elementName); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void parseProperty(Map<String, String> r, final XMLStreamReader reader, String ver) | ||
static void parseProperty(Map<String, String> r, final XMLStreamReader reader, String context, String ver) | ||
throws XMLStreamException { | ||
String name = null, value = null; | ||
while (reader.hasNext()) { | ||
|
@@ -374,9 +369,7 @@ public static void parseProperty(Map<String, String> r, final XMLStreamReader re | |
} | ||
break; | ||
default: | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
LOGGER.finest("CaseResult.parseProperty encountered an unknown field: " + elementName); | ||
} | ||
LOGGER.finest(() -> "Unknown field in " + context + ": " + elementName); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import jenkins.tasks.SimpleBuildStep; | ||
|
@@ -69,7 +70,6 @@ | |
@SuppressFBWarnings(value = "UG_SYNC_SET_UNSYNC_GET", justification = "False positive") | ||
public class TestResultAction extends AbstractTestResultAction<TestResultAction> | ||
implements StaplerProxy, SimpleBuildStep.LastBuildAction { | ||
private static final Logger LOGGER = Logger.getLogger(TestResultAction.class.getName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was added in #625, but we already had a logger at the bottom of the file, it was just named lowercase |
||
private transient WeakReference<TestResult> result; | ||
|
||
/** null only if there is a {@link JunitTestResultStorage} */ | ||
|
@@ -179,8 +179,8 @@ public synchronized TestResult getResult() { | |
skipCount = r.getSkipCount(); | ||
} | ||
long d = System.nanoTime() - started; | ||
if (d > 500000000L && LOGGER.isLoggable(Level.WARNING)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 500000000 is 5e8, or 0.5 seconds. I adjusted the code to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I also wonder if this threshold is too low for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of setting the threshold higher for logging at less than 2 seconds, but approve this pull request with or without that change. |
||
LOGGER.warning("TestResultAction.load took " + d / 1000000L + " ms."); | ||
if (d > TimeUnit.MILLISECONDS.toNanos(500)) { | ||
logger.warning(() -> "Took " + TimeUnit.NANOSECONDS.toMillis(d) + " ms to load test results for " + run); | ||
} | ||
return r; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know nothing should be using these new methods from #625, so I made them all package-private, but if that is not true, let me know and I will revert that part of the change.