mirror of https://github.com/apache/maven.git
[MNG-7822] Add support for TRACE logging level (with style "bold,magenta") (#1215)
Signed-off-by: crazyhzm <crazyhzm@apache.org>
This commit is contained in:
parent
f2593b97ef
commit
7d66d19f8b
|
@ -27,9 +27,21 @@
|
||||||
* @see MessageBuilderFactory
|
* @see MessageBuilderFactory
|
||||||
*/
|
*/
|
||||||
public interface MessageBuilder {
|
public interface MessageBuilder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append message content in trace style.
|
||||||
|
* By default, bold magenta
|
||||||
|
*
|
||||||
|
* @param message the message to append
|
||||||
|
* @return the current builder
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
MessageBuilder trace(Object message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append message content in debug style.
|
* Append message content in debug style.
|
||||||
* By default, bold cyan
|
* By default, bold cyan
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +51,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in info style.
|
* Append message content in info style.
|
||||||
* By default, bold blue
|
* By default, bold blue
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -48,6 +61,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in warning style.
|
* Append message content in warning style.
|
||||||
* By default, bold yellow
|
* By default, bold yellow
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -57,6 +71,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in error style.
|
* Append message content in error style.
|
||||||
* By default, bold red
|
* By default, bold red
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -66,6 +81,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in success style.
|
* Append message content in success style.
|
||||||
* By default, bold green
|
* By default, bold green
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +91,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in failure style.
|
* Append message content in failure style.
|
||||||
* By default, bold red
|
* By default, bold red
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -84,6 +101,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in strong style.
|
* Append message content in strong style.
|
||||||
* By default, bold
|
* By default, bold
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -93,6 +111,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in mojo style.
|
* Append message content in mojo style.
|
||||||
* By default, green
|
* By default, green
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -102,6 +121,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append message content in project style.
|
* Append message content in project style.
|
||||||
* By default, cyan
|
* By default, cyan
|
||||||
|
*
|
||||||
* @param message the message to append
|
* @param message the message to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -113,6 +133,7 @@ public interface MessageBuilder {
|
||||||
//
|
//
|
||||||
/**
|
/**
|
||||||
* Append content to the message buffer.
|
* Append content to the message buffer.
|
||||||
|
*
|
||||||
* @param value the content to append
|
* @param value the content to append
|
||||||
* @param offset the index of the first {@code char} to append
|
* @param offset the index of the first {@code char} to append
|
||||||
* @param len the number of {@code char}s to append
|
* @param len the number of {@code char}s to append
|
||||||
|
@ -123,6 +144,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append content to the message buffer.
|
* Append content to the message buffer.
|
||||||
|
*
|
||||||
* @param value the content to append
|
* @param value the content to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -131,6 +153,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append content to the message buffer.
|
* Append content to the message buffer.
|
||||||
|
*
|
||||||
* @param value the content to append
|
* @param value the content to append
|
||||||
* @param start the starting index of the subsequence to be appended
|
* @param start the starting index of the subsequence to be appended
|
||||||
* @param end the end index of the subsequence to be appended
|
* @param end the end index of the subsequence to be appended
|
||||||
|
@ -141,6 +164,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append content to the message buffer.
|
* Append content to the message buffer.
|
||||||
|
*
|
||||||
* @param value the content to append
|
* @param value the content to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -149,6 +173,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append content to the message buffer.
|
* Append content to the message buffer.
|
||||||
|
*
|
||||||
* @param value the content to append
|
* @param value the content to append
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +182,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append newline to the message buffer.
|
* Append newline to the message buffer.
|
||||||
|
*
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -165,6 +191,7 @@ public interface MessageBuilder {
|
||||||
/**
|
/**
|
||||||
* Append formatted content to the buffer.
|
* Append formatted content to the buffer.
|
||||||
* @see String#format(String, Object...)
|
* @see String#format(String, Object...)
|
||||||
|
*
|
||||||
* @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
|
* @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
|
||||||
* @param args arguments referenced by the format specifiers in the format string
|
* @param args arguments referenced by the format specifiers in the format string
|
||||||
* @return the current builder
|
* @return the current builder
|
||||||
|
@ -174,6 +201,7 @@ public interface MessageBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the built message.
|
* Return the built message.
|
||||||
|
*
|
||||||
* @return the message
|
* @return the message
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -35,6 +35,12 @@ public DefaultMessageBuilder(StringBuilder buffer) {
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public MessageBuilder trace(Object o) {
|
||||||
|
return a(o);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public MessageBuilder debug(Object o) {
|
public MessageBuilder debug(Object o) {
|
||||||
|
|
|
@ -594,6 +594,7 @@ private void commands(CliRequest cliRequest) {
|
||||||
if (MessageUtils.isColorEnabled()) {
|
if (MessageUtils.isColorEnabled()) {
|
||||||
MessageBuilder buff = MessageUtils.builder();
|
MessageBuilder buff = MessageUtils.builder();
|
||||||
buff.a("Message styles: ");
|
buff.a("Message styles: ");
|
||||||
|
buff.trace("trace").a(' ');
|
||||||
buff.debug("debug").a(' ');
|
buff.debug("debug").a(' ');
|
||||||
buff.info("info").a(' ');
|
buff.info("info").a(' ');
|
||||||
buff.warning("warning").a(' ');
|
buff.warning("warning").a(' ');
|
||||||
|
|
|
@ -35,6 +35,12 @@ public JansiMessageBuilder(StringBuilder sb) {
|
||||||
this.ansi = Ansi.ansi(sb);
|
this.ansi = Ansi.ansi(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public MessageBuilder trace(Object o) {
|
||||||
|
return style(Style.TRACE, o);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public MessageBuilder debug(Object o) {
|
public MessageBuilder debug(Object o) {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
enum Style {
|
enum Style {
|
||||||
|
TRACE("bold,magenta"),
|
||||||
DEBUG("bold,cyan"),
|
DEBUG("bold,cyan"),
|
||||||
INFO("bold,blue"),
|
INFO("bold,blue"),
|
||||||
WARNING("bold,yellow"),
|
WARNING("bold,yellow"),
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MavenSimpleLogger extends SimpleLogger {
|
||||||
protected String renderLevel(int level) {
|
protected String renderLevel(int level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG_LEVEL_TRACE:
|
case LOG_LEVEL_TRACE:
|
||||||
return builder().debug("TRACE").build();
|
return builder().trace("TRACE").build();
|
||||||
case LOG_LEVEL_DEBUG:
|
case LOG_LEVEL_DEBUG:
|
||||||
return builder().debug("DEBUG").build();
|
return builder().debug("DEBUG").build();
|
||||||
case LOG_LEVEL_INFO:
|
case LOG_LEVEL_INFO:
|
||||||
|
|
Loading…
Reference in New Issue