Skip to content

Commit

Permalink
Use @MessageLogger to log messages in function module
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Sep 26, 2023
1 parent cde3a19 commit cda3e28
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
8 changes: 8 additions & 0 deletions function/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@
import java.util.function.ToLongBiFunction;
import java.util.function.ToLongFunction;

import org.jboss.logging.Logger;

import io.smallrye.common.constraint.Assert;

/**
* A set of utility methods which return common functions.
*/
public final class Functions {

private static final Logger LOGGER = Logger.getLogger(Functions.class);

private Functions() {
}

Expand Down Expand Up @@ -344,7 +339,7 @@ public static <T extends AutoCloseable> Consumer<T> closingConsumer() {
private static final Consumer<Exception> EXCEPTION_LOGGER = new Consumer<>() {
@Override
public void accept(Exception e) {
LOGGER.warn(e.getLocalizedMessage(), e);
FunctionsLogging.log.exception(e.getMessage(), e);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.smallrye.common.function;

import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

@MessageLogger(projectCode = "SRCFG", length = 5)
public interface FunctionsLogging {
FunctionsLogging log = Logger.getMessageLogger(FunctionsLogging.class, FunctionsLogging.class.getPackage().getName());

@LogMessage(level = Logger.Level.WARN)
@Message(id = 4000, value = "%s")
void exception(String message, @Cause Throwable cause);
}
10 changes: 5 additions & 5 deletions message-ranges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

# Range = owner

00000-00999 = smallrye-common-constraint
00000-00999 = smallrye-common-constraint (messages)

01000-01999 = smallrye-common-expression
01000-01999 = smallrye-common-expression (messages)

02000-02999 = smallrye-common-net
02000-02999 = smallrye-common-net (messages)

03000-03999 =
03000-03999 = smallrye-version (messages)

04000-04999 =
04000-04999 = smallrye-function (logging)

05000-05999 =

Expand Down

0 comments on commit cda3e28

Please sign in to comment.