Skip to content

Commit

Permalink
Merge pull request eclipse-tycho#469 from laeubi/add_debug_exception_…
Browse files Browse the repository at this point in the history
…to_maven_logger

Add a debug(msg, exception) method to the maven logger
  • Loading branch information
laeubi committed Jan 2, 2022
2 parents 6026816 + b47f960 commit 8712fe5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Expand Up @@ -31,6 +31,8 @@ public interface MavenLogger {

public void debug(String message);

public void debug(String message, Throwable cause);

public boolean isDebugEnabled();

public boolean isExtendedDebugEnabled();
Expand Down
Expand Up @@ -88,6 +88,19 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable cause) {
String[] messageLines = message.split("\n");
for (int ix = 0; ix < messageLines.length - 1; ix++) {
String messageLine = messageLines[ix];
delegate.debug(messageLine);
}
if (messageLines.length > 0) {
String lastMessageLine = messageLines[messageLines.length - 1];
delegate.error(lastMessageLine, cause);
}
}

@Override
public boolean isDebugEnabled() {
return delegate.isDebugEnabled();
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2021 SAP SE and others.
* Copyright (c) 2011, 2022 SAP SE and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -140,6 +140,11 @@ public boolean isDebugEnabled() {
public boolean isExtendedDebugEnabled() {
return true;
}

@Override
public void debug(String message, Throwable cause) {

}
}

}
Expand Up @@ -72,6 +72,11 @@ public void warn(String message, Throwable cause) {
warn(message);
}

@Override
public void debug(String message, Throwable cause) {
debug(message);
}

@Override
public void info(String message) {
infos.append(message);
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2021 SAP AG and others.
* Copyright (c) 2011, 2022 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -31,6 +31,13 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable cause) {
if (!isEmpty(message)) {
logger.debug(message, cause);
}
}

@Override
public void info(String message) {
if (!isEmpty(message)) {
Expand Down

0 comments on commit 8712fe5

Please sign in to comment.