-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a97c36
commit ecd15b0
Showing
6 changed files
with
454 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
versions-enforcer/src/main/java/org/codehaus/mojo/versions/enforcer/PluginLogWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package org.codehaus.mojo.versions.enforcer; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
|
||
import org.apache.maven.enforcer.rule.api.EnforcerLogger; | ||
import org.apache.maven.plugin.logging.Log; | ||
|
||
/** | ||
* Wrapper used to pass {@link EnforcerLogger} as Maven plugin {@link Log}. | ||
*/ | ||
class PluginLogWrapper implements Log { | ||
|
||
private final EnforcerLogger logger; | ||
|
||
PluginLogWrapper(EnforcerLogger logger) { | ||
this.logger = logger; | ||
} | ||
|
||
@Override | ||
public boolean isDebugEnabled() { | ||
return logger.isDebugEnabled(); | ||
} | ||
|
||
@Override | ||
public void debug(CharSequence charSequence) { | ||
logger.debug(charSequence); | ||
} | ||
|
||
@Override | ||
public void debug(CharSequence charSequence, Throwable throwable) { | ||
logger.debug(charSequence + throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public void debug(Throwable throwable) { | ||
logger.debug(throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public boolean isInfoEnabled() { | ||
return logger.isInfoEnabled(); | ||
} | ||
|
||
@Override | ||
public void info(CharSequence charSequence) { | ||
logger.info(charSequence); | ||
} | ||
|
||
@Override | ||
public void info(CharSequence charSequence, Throwable throwable) { | ||
|
||
logger.info(charSequence + throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public void info(Throwable throwable) { | ||
logger.info(throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public boolean isWarnEnabled() { | ||
return logger.isWarnEnabled(); | ||
} | ||
|
||
@Override | ||
public void warn(CharSequence charSequence) { | ||
logger.warn(charSequence); | ||
} | ||
|
||
@Override | ||
public void warn(CharSequence charSequence, Throwable throwable) { | ||
logger.warn(charSequence + throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public void warn(Throwable throwable) { | ||
logger.warn(throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public boolean isErrorEnabled() { | ||
return logger.isErrorEnabled(); | ||
} | ||
|
||
@Override | ||
public void error(CharSequence charSequence) { | ||
logger.error(charSequence); | ||
} | ||
|
||
@Override | ||
public void error(CharSequence charSequence, Throwable throwable) { | ||
logger.error(charSequence + throwableToString(throwable)); | ||
} | ||
|
||
@Override | ||
public void error(Throwable throwable) { | ||
logger.error(throwableToString(throwable)); | ||
} | ||
|
||
private String throwableToString(Throwable throwable) { | ||
if (throwable != null) { | ||
ByteArrayOutputStream stream = new ByteArrayOutputStream(); | ||
throwable.printStackTrace(new PrintStream(stream)); | ||
return System.lineSeparator() + stream; | ||
} | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.