Skip to content
Snippets Groups Projects
Commit 7d573a53 authored by brinn's avatar brinn
Browse files

refactor:

- make the ISimpleLogger.LogLevel a top level class
change:
- add LogLevel.UNDEFINED and LogLevel.TRACE

SVN: 4328
parent 3dad30a2
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ import org.apache.tools.ant.Project; ...@@ -20,6 +20,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.logging.ISimpleLogger;
import ch.systemsx.cisd.common.logging.LogLevel;
/** /**
* An adapter of a ant task to an {@link ISimpleLogger}. * An adapter of a ant task to an {@link ISimpleLogger}.
...@@ -31,15 +32,23 @@ public class AntTaskSimpleLoggerAdapter implements ISimpleLogger ...@@ -31,15 +32,23 @@ public class AntTaskSimpleLoggerAdapter implements ISimpleLogger
private final Task antTask; private final Task antTask;
private final static int toAntLogLevel(ISimpleLogger.Level level) private final static int toAntLogLevel(LogLevel level)
{ {
switch (level) switch (level)
{ {
case ERROR: return Project.MSG_ERR; case OFF:
case WARN: return Project.MSG_WARN; return Project.MSG_DEBUG;
case INFO: return Project.MSG_INFO; case TRACE:
case DEBUG: return Project.MSG_DEBUG; return Project.MSG_VERBOSE;
default: throw new IllegalArgumentException("Unknonwn log level " + level); case DEBUG:
return Project.MSG_DEBUG;
case INFO:
return Project.MSG_INFO;
case WARN:
return Project.MSG_WARN;
case ERROR:
return Project.MSG_ERR;
default: throw new IllegalArgumentException("Illegal log level " + level);
} }
} }
...@@ -48,7 +57,7 @@ public class AntTaskSimpleLoggerAdapter implements ISimpleLogger ...@@ -48,7 +57,7 @@ public class AntTaskSimpleLoggerAdapter implements ISimpleLogger
this.antTask = antTask; this.antTask = antTask;
} }
public void log(ISimpleLogger.Level level, String message) public void log(LogLevel level, String message)
{ {
antTask.log(message, toAntLogLevel(level)); antTask.log(message, toAntLogLevel(level));
} }
......
...@@ -32,7 +32,7 @@ import ch.systemsx.cisd.ant.common.StringUtils; ...@@ -32,7 +32,7 @@ import ch.systemsx.cisd.ant.common.StringUtils;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.logging.ISimpleLogger;
import ch.systemsx.cisd.common.logging.ISimpleLogger.Level; import ch.systemsx.cisd.common.logging.LogLevel;
import ch.systemsx.cisd.common.utilities.OSUtilities; import ch.systemsx.cisd.common.utilities.OSUtilities;
/** /**
...@@ -271,7 +271,7 @@ class SVNUtilities ...@@ -271,7 +271,7 @@ class SVNUtilities
final ProcessBuilder builder = new ProcessBuilder(fullCommand); final ProcessBuilder builder = new ProcessBuilder(fullCommand);
builder.redirectErrorStream(redirectErrorStream); builder.redirectErrorStream(redirectErrorStream);
final String commandString = StringUtils.join(builder.command(), " "); final String commandString = StringUtils.join(builder.command(), " ");
logger.log(Level.INFO, String.format("Executing '%s'", commandString)); logger.log(LogLevel.INFO, String.format("Executing '%s'", commandString));
try try
{ {
final Process process = builder.start(); final Process process = builder.start();
...@@ -318,7 +318,7 @@ class SVNUtilities ...@@ -318,7 +318,7 @@ class SVNUtilities
final ProcessBuilder builder = new ProcessBuilder(fullCommand); final ProcessBuilder builder = new ProcessBuilder(fullCommand);
builder.redirectErrorStream(true); builder.redirectErrorStream(true);
final String commandString = StringUtils.join(builder.command(), " "); final String commandString = StringUtils.join(builder.command(), " ");
logger.log(Level.INFO, String.format("Executing '%s'", commandString)); logger.log(LogLevel.INFO, String.format("Executing '%s'", commandString));
try try
{ {
final Process process = builder.start(); final Process process = builder.start();
...@@ -347,7 +347,7 @@ class SVNUtilities ...@@ -347,7 +347,7 @@ class SVNUtilities
{ {
for (String line : output) for (String line : output)
{ {
logger.log(Level.INFO, String.format("SVN > %s", line)); logger.log(LogLevel.INFO, String.format("SVN > %s", line));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment