Skip to content

Commit

Permalink
Make PrefixLogger public.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Apr 15, 2020
1 parent a074b05 commit 720f2df
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/main/java/edu/hm/hafner/util/PrefixLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@
*
* @author Ullrich Hafner
*/
class PrefixLogger {
public class PrefixLogger {
private final String toolName;
private final PrintStream delegate;

PrefixLogger(final PrintStream logger, final String toolName) {
if (toolName.contains("[")) {
this.toolName = toolName + " ";
/**
* Creates a new {@link PrefixLogger}.
*
* @param logger
* the logger to create
* @param prefix
* the prefix to print
*/
public PrefixLogger(final PrintStream logger, final String prefix) {
if (prefix.contains("[")) {
this.toolName = prefix + " ";
}
else {
this.toolName = String.format("[%s] ", toolName);
this.toolName = String.format("[%s] ", prefix);
}
delegate = logger;
}
Expand All @@ -35,7 +43,7 @@ class PrefixLogger {
* zero.
*/
@FormatMethod
void log(final String format, final Object... args) {
public void log(final String format, final Object... args) {
print(String.format(format, args));
}

Expand All @@ -45,7 +53,7 @@ void log(final String format, final Object... args) {
* @param lines
* the messages to log
*/
void logEachLine(final Collection<String> lines) {
public void logEachLine(final Collection<String> lines) {
lines.forEach(this::print);
}

Expand Down

0 comments on commit 720f2df

Please sign in to comment.