forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#3951 from cescoffier/features/vertx-exte…
…nsion-improvements Various improvement around the Vert.x extensions
- Loading branch information
Showing
69 changed files
with
1,557 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ertx-core/deployment/src/test/java/io/quarkus/vertx/core/deployment/VertxLoggingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.quarkus.vertx.core.deployment; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.impl.NoStackTraceThrowable; | ||
import io.vertx.core.logging.Logger; | ||
import io.vertx.core.logging.LoggerFactory; | ||
|
||
public class VertxLoggingTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(BeanThatLog.class)); | ||
|
||
@Inject | ||
BeanThatLog bean; | ||
|
||
@Test | ||
public void test() { | ||
bean.info(); | ||
|
||
bean.trace(); | ||
} | ||
|
||
@ApplicationScoped | ||
static class BeanThatLog { | ||
|
||
private final static Logger LOGGER = LoggerFactory.getLogger("verbose-bean"); | ||
|
||
public void info() { | ||
LOGGER.info("Info"); | ||
LOGGER.info("Info with exception", new NoStackTraceThrowable("boom")); | ||
LOGGER.info("Info with parameters {0} {1}", "Quarkus", 1); | ||
LOGGER.info("Info with exception and param {0}", new NoStackTraceThrowable("boom"), "quarkus"); | ||
LOGGER.info("Info with exception as last param {0}", "quarkus", new NoStackTraceThrowable("boom")); | ||
LOGGER.info("Info with null as failure", (Throwable) null); | ||
LOGGER.info("Info with null as parameter {0}", (String) null); | ||
|
||
// Null message -> NULL | ||
LOGGER.info(null); | ||
} | ||
|
||
public void trace() { | ||
LOGGER.trace("Should not be displayed"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...ions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxLogDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package io.quarkus.vertx.core.runtime; | ||
|
||
import java.util.logging.LogRecord; | ||
|
||
import org.jboss.logmanager.Level; | ||
import org.jboss.logmanager.Logger; | ||
|
||
import io.vertx.core.spi.logging.LogDelegate; | ||
|
||
public class VertxLogDelegate implements LogDelegate { | ||
private final Logger logger; | ||
|
||
public VertxLogDelegate(String name) { | ||
this.logger = Logger.getLogger(name); | ||
} | ||
|
||
@Override | ||
public boolean isWarnEnabled() { | ||
return logger.isLoggable(Level.WARN); | ||
} | ||
|
||
public boolean isInfoEnabled() { | ||
return logger.isLoggable(Level.INFO); | ||
} | ||
|
||
public boolean isDebugEnabled() { | ||
return logger.isLoggable(Level.DEBUG); | ||
} | ||
|
||
public boolean isTraceEnabled() { | ||
return logger.isLoggable(Level.TRACE); | ||
} | ||
|
||
public void fatal(final Object message) { | ||
log(Level.FATAL, message); | ||
} | ||
|
||
public void fatal(final Object message, final Throwable t) { | ||
log(Level.FATAL, message, t); | ||
} | ||
|
||
public void error(final Object message) { | ||
log(Level.ERROR, message); | ||
} | ||
|
||
@Override | ||
public void error(Object message, Object... params) { | ||
log(Level.ERROR, message, null, params); | ||
} | ||
|
||
public void error(final Object message, final Throwable t) { | ||
log(Level.ERROR, message, t); | ||
} | ||
|
||
@Override | ||
public void error(Object message, Throwable t, Object... params) { | ||
log(Level.ERROR, message, t, params); | ||
} | ||
|
||
public void warn(final Object message) { | ||
log(Level.WARN, message); | ||
} | ||
|
||
@Override | ||
public void warn(Object message, Object... params) { | ||
log(Level.WARN, message, null, params); | ||
} | ||
|
||
public void warn(final Object message, final Throwable t) { | ||
log(Level.WARN, message, t); | ||
} | ||
|
||
@Override | ||
public void warn(Object message, Throwable t, Object... params) { | ||
log(Level.WARN, message, t, params); | ||
} | ||
|
||
public void info(final Object message) { | ||
log(Level.INFO, message); | ||
} | ||
|
||
@Override | ||
public void info(Object message, Object... params) { | ||
log(Level.INFO, message, null, params); | ||
} | ||
|
||
public void info(final Object message, final Throwable t) { | ||
log(Level.INFO, message, t); | ||
} | ||
|
||
@Override | ||
public void info(Object message, Throwable t, Object... params) { | ||
log(Level.INFO, message, t, params); | ||
} | ||
|
||
public void debug(final Object message) { | ||
log(Level.DEBUG, message); | ||
} | ||
|
||
@Override | ||
public void debug(Object message, Object... params) { | ||
log(Level.DEBUG, message, null, params); | ||
} | ||
|
||
public void debug(final Object message, final Throwable t) { | ||
log(Level.DEBUG, message, t); | ||
} | ||
|
||
@Override | ||
public void debug(Object message, Throwable t, Object... params) { | ||
log(Level.DEBUG, message, t, params); | ||
} | ||
|
||
public void trace(final Object message) { | ||
log(Level.TRACE, message); | ||
} | ||
|
||
@Override | ||
public void trace(Object message, Object... params) { | ||
log(Level.TRACE, message, null, params); | ||
} | ||
|
||
public void trace(final Object message, final Throwable t) { | ||
log(Level.TRACE, message, t); | ||
} | ||
|
||
@Override | ||
public void trace(Object message, Throwable t, Object... params) { | ||
log(Level.TRACE, message, t, params); | ||
} | ||
|
||
private void log(Level level, Object message) { | ||
log(level, message, null); | ||
} | ||
|
||
private void log(Level level, Object message, Throwable t, Object... params) { | ||
if (!logger.isLoggable(level)) { | ||
return; | ||
} | ||
String msg = (message == null) ? "NULL" : message.toString(); | ||
LogRecord record = new LogRecord(level, msg); | ||
record.setLoggerName(logger.getName()); | ||
if (t != null) { | ||
record.setThrown(t); | ||
} else if (params != null && params.length != 0 && params[params.length - 1] instanceof Throwable) { | ||
// The exception may be the last parameters (SLF4J uses this convention). | ||
// As the logger can be used in a SLF4J style, we need to check | ||
record.setThrown((Throwable) params[params.length - 1]); | ||
} | ||
record.setSourceClassName(null); | ||
record.setParameters(params); | ||
logger.log(record); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...rtx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxLogDelegateFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkus.vertx.core.runtime; | ||
|
||
import io.vertx.core.spi.logging.LogDelegate; | ||
import io.vertx.core.spi.logging.LogDelegateFactory; | ||
|
||
public class VertxLogDelegateFactory implements LogDelegateFactory { | ||
@Override | ||
public LogDelegate createDelegate(String name) { | ||
return new VertxLogDelegate(name); | ||
} | ||
} |
Oops, something went wrong.