Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@
* @see MessageBuilderFactory
*/
public interface MessageBuilder {

/**
* Append message content in trace style.
* By default, bold magenta
*
* @param message the message to append
Comment thread
CrazyHZM marked this conversation as resolved.
* @return the current builder
*/
@Nonnull
MessageBuilder trace(Object message);

/**
* Append message content in debug style.
* By default, bold cyan
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -39,6 +51,7 @@ public interface MessageBuilder {
/**
* Append message content in info style.
* By default, bold blue
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -48,6 +61,7 @@ public interface MessageBuilder {
/**
* Append message content in warning style.
* By default, bold yellow
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -57,6 +71,7 @@ public interface MessageBuilder {
/**
* Append message content in error style.
* By default, bold red
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -66,6 +81,7 @@ public interface MessageBuilder {
/**
* Append message content in success style.
* By default, bold green
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -75,6 +91,7 @@ public interface MessageBuilder {
/**
* Append message content in failure style.
* By default, bold red
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -84,6 +101,7 @@ public interface MessageBuilder {
/**
* Append message content in strong style.
* By default, bold
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -93,6 +111,7 @@ public interface MessageBuilder {
/**
* Append message content in mojo style.
* By default, green
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -102,6 +121,7 @@ public interface MessageBuilder {
/**
* Append message content in project style.
* By default, cyan
*
* @param message the message to append
* @return the current builder
*/
Expand All @@ -113,6 +133,7 @@ public interface MessageBuilder {
//
/**
* Append content to the message buffer.
*
* @param value the content to append
* @param offset the index of the first {@code char} to append
* @param len the number of {@code char}s to append
Expand All @@ -123,6 +144,7 @@ public interface MessageBuilder {

/**
* Append content to the message buffer.
*
* @param value the content to append
* @return the current builder
*/
Expand All @@ -131,6 +153,7 @@ public interface MessageBuilder {

/**
* Append content to the message buffer.
*
* @param value the content to append
* @param start the starting index of the subsequence to be appended
* @param end the end index of the subsequence to be appended
Expand All @@ -141,6 +164,7 @@ public interface MessageBuilder {

/**
* Append content to the message buffer.
*
* @param value the content to append
* @return the current builder
*/
Expand All @@ -149,6 +173,7 @@ public interface MessageBuilder {

/**
* Append content to the message buffer.
*
* @param value the content to append
* @return the current builder
*/
Expand All @@ -157,6 +182,7 @@ public interface MessageBuilder {

/**
* Append newline to the message buffer.
*
* @return the current builder
*/
@Nonnull
Expand All @@ -165,6 +191,7 @@ public interface MessageBuilder {
/**
* Append formatted content to the buffer.
* @see String#format(String, Object...)
*
* @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
* @param args arguments referenced by the format specifiers in the format string
* @return the current builder
Expand All @@ -174,6 +201,7 @@ public interface MessageBuilder {

/**
* Return the built message.
*
* @return the message
*/
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public DefaultMessageBuilder(StringBuilder buffer) {
this.buffer = buffer;
}

@Override
@Nonnull
public MessageBuilder trace(Object o) {
return a(o);
}

@Override
@Nonnull
public MessageBuilder debug(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ private void commands(CliRequest cliRequest) {
if (MessageUtils.isColorEnabled()) {
MessageBuilder buff = MessageUtils.builder();
buff.a("Message styles: ");
buff.trace("trace").a(' ');
buff.debug("debug").a(' ');
buff.info("info").a(' ');
buff.warning("warning").a(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public JansiMessageBuilder(StringBuilder sb) {
this.ansi = Ansi.ansi(sb);
}

@Override
@Nonnull
public MessageBuilder trace(Object o) {
return style(Style.TRACE, o);
}

@Override
@Nonnull
public MessageBuilder debug(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @since 4.0.0
*/
enum Style {
TRACE("bold,magenta"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be last to avoid changing existing ordinals in an incompatible way.

Copy link
Copy Markdown
Contributor

@gnodet gnodet Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an existing one, as it only has been introduced in 4.0, so it should be safe here.

DEBUG("bold,cyan"),
INFO("bold,blue"),
WARNING("bold,yellow"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MavenSimpleLogger extends SimpleLogger {
protected String renderLevel(int level) {
switch (level) {
case LOG_LEVEL_TRACE:
return builder().debug("TRACE").build();
return builder().trace("TRACE").build();
case LOG_LEVEL_DEBUG:
return builder().debug("DEBUG").build();
case LOG_LEVEL_INFO:
Expand Down