Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3382 from batmat/JENKINS-50291-followup
Log the message only once in INFO level
  • Loading branch information
batmat committed Apr 8, 2018
2 parents 70c408c + 75df729 commit d366abc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/src/main/java/hudson/triggers/SafeTimerTask.java
Expand Up @@ -58,6 +58,12 @@ public abstract class SafeTimerTask extends TimerTask {
*/
static final String LOGS_ROOT_PATH_PROPERTY = SafeTimerTask.class.getName()+".logsTargetDir";

/**
* Local marker to know if the information about using non default root directory for logs has already been logged at least once.
* @see #LOGS_ROOT_PATH_PROPERTY
*/
private static boolean ALREADY_LOGGED = false;

public final void run() {
// background activity gets system credential,
// just like executors get it.
Expand Down Expand Up @@ -87,9 +93,14 @@ public static File getLogsRoot() {
if (tagsLogsPath == null) {
return new File(Jenkins.get().getRootDir(), "logs");
} else {
LOGGER.log(Level.INFO,
Level logLevel = Level.INFO;
if (ALREADY_LOGGED) {
logLevel = Level.FINE;
}
LOGGER.log(logLevel,
"Using non default root path for tasks logging: {0}. (Beware: no automated migration if you change or remove it again)",
LOGS_ROOT_PATH_PROPERTY);
ALREADY_LOGGED = true;
return new File(tagsLogsPath);
}
}
Expand Down

0 comments on commit d366abc

Please sign in to comment.