本文整理了Java中reactor.util.Logger.warn()
方法的一些代码示例,展示了Logger.warn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()
方法的具体详情如下:
包路径:reactor.util.Logger
类名称:Logger
方法名:warn
[英]Log a message at the WARN level.
[中]
代码示例来源:origin: reactor/reactor-core
@Override
public void warn(String msg) {
delegate.warn(msg);
}
代码示例来源:origin: reactor/reactor-core
@Override
public void warn(String msg, Throwable t) {
delegate.warn(msg, t);
}
代码示例来源:origin: reactor/reactor-core
@Override
public void onError(Throwable e) {
Loggers.getLogger(FluxUsingWhen.class).warn("Async resource cleanup failed after cancel", e);
}
代码示例来源:origin: reactor/reactor-core
/**
* Invoke a (local or global) hook that processes elements that get discarded en masse.
* This includes elements that are buffered but subsequently discarded due to
* cancellation or error.
*
* @param multiple the collection of elements to discard (possibly extracted from other
* collections/arrays/queues)
* @param context the {@link Context} in which to look for local hook
* @see #onDiscard(Object, Context)
* @see #onDiscardMultiple(Collection, Context)
* @see #onDiscardQueueWithClear(Queue, Context, Function)
*/
public static void onDiscardMultiple(Stream<?> multiple, Context context) {
Consumer<Object> hook = context.getOrDefault(Hooks.KEY_ON_DISCARD, null);
if (hook != null) {
try {
multiple.forEach(hook);
}
catch (Throwable t) {
log.warn("Error in discard hook while discarding multiple values", t);
}
}
}
代码示例来源:origin: reactor/reactor-core
/**
* Invoke a (local or global) hook that processes elements that get discarded en masse.
* This includes elements that are buffered but subsequently discarded due to
* cancellation or error.
*
* @param multiple the collection of elements to discard
* @param context the {@link Context} in which to look for local hook
* @see #onDiscard(Object, Context)
* @see #onDiscardMultiple(Stream, Context)
* @see #onDiscardQueueWithClear(Queue, Context, Function)
*/
public static void onDiscardMultiple(@Nullable Collection<?> multiple, Context context) {
if (multiple == null) return;
Consumer<Object> hook = context.getOrDefault(Hooks.KEY_ON_DISCARD, null);
if (hook != null) {
try {
multiple.forEach(hook);
}
catch (Throwable t) {
log.warn("Error in discard hook while discarding multiple values", t);
}
}
}
代码示例来源:origin: reactor/reactor-core
/**
* Invoke a (local or global) hook that processes elements that get discarded. This
* includes elements that are dropped (for malformed sources), but also filtered out
* (eg. not passing a {@code filter()} predicate).
* <p>
* For elements that are buffered or enqueued, but subsequently discarded due to
* cancellation or error, see {@link #onDiscardMultiple(Stream, Context)} and
* {@link #onDiscardQueueWithClear(Queue, Context, Function)}.
*
* @param element the element that is being discarded
* @param context the context in which to look for a local hook
* @param <T> the type of the element
* @see #onDiscardMultiple(Stream, Context)
* @see #onDiscardMultiple(Collection, Context)
* @see #onDiscardQueueWithClear(Queue, Context, Function)
*/
public static <T> void onDiscard(@Nullable T element, Context context) {
Consumer<Object> hook = context.getOrDefault(Hooks.KEY_ON_DISCARD, null);
if (element != null && hook != null) {
try {
hook.accept(element);
}
catch (Throwable t) {
log.warn("Error in discard hook", t);
}
}
}
代码示例来源:origin: reactor/reactor-core
@Override
public void warn(String format, Object... arguments) {
delegate.warn(format, wrapArguments(arguments));
}
代码示例来源:origin: reactor/reactor-core
log.warn("Error in discard hook while discarding and clearing a queue", t);
代码示例来源:origin: reactor/reactor-core
@Test
public void warn1() throws Exception {
logger.warn("message {} {} format", "with", 1);
assertThat(outContent.size()).isZero();
assertThat(errContent.toString()).isEqualTo("[ WARN] (" + Thread.currentThread().getName() + ") message with 1 format\n");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void warn() throws Exception {
logger.warn("message");
assertThat(outContent.size()).isZero();
assertThat(errContent.toString()).isEqualTo("[ WARN] (" + Thread.currentThread().getName() + ") message\n");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void warnNulls() {
logger.warn("vararg {} is {}", (Object[]) null);
logger.warn("param {} is {}", null, null);
assertThat(errContent.toString())
.contains("vararg {} is {}")
.contains("param null is null");
assertThat(outContent.size()).isZero();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void warn2() throws Exception {
logger.warn("with cause", CAUSE);
assertThat(outContent.size()).isZero();
assertThat(errContent.toString())
.startsWith("[ WARN] (" + Thread.currentThread().getName() + ") with cause - java.lang.IllegalStateException: cause" +
"\njava.lang.IllegalStateException: cause\n" +
"\tat reactor.util.ConsoleLoggerTest");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoLogWithGivenLogger() {
Level level = Level.WARNING;
Mono<String> source = Mono.just("foo");
Logger mockLogger = Mockito.mock(Logger.class);
source.log(mockLogger, level, false, SignalType.ON_NEXT)
.subscribe();
verify(mockLogger, only()).warn(anyString(), eq(SignalType.ON_NEXT),
eq("foo"));
verifyNoMoreInteractions(mockLogger);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void fluxLogWithGivenLogger() {
Level level = Level.WARNING;
Flux<String> source = Flux.just("foo");
Logger mockLogger = Mockito.mock(Logger.class);
source.log(mockLogger, level, false, SignalType.ON_NEXT)
.subscribe();
verify(mockLogger, only()).warn(anyString(), eq(SignalType.ON_NEXT),
eq("foo"));
verifyNoMoreInteractions(mockLogger);
}
代码示例来源:origin: reactor/reactor-core
@Override
public void cancel() {
if (CALLBACK_APPLIED.compareAndSet(this, 0, 1)) {
if (Operators.terminate(SUBSCRIPTION, this)) {
try {
if (asyncCancel != null) {
Flux.from(asyncCancel.apply(resource))
.subscribe(new CancelInner(this));
}
else {
Flux.from(asyncComplete.apply(resource))
.subscribe(new CancelInner(this));
}
}
catch (Throwable error) {
Loggers.getLogger(FluxUsingWhen.class).warn("Error generating async resource cleanup during onCancel", error);
}
}
}
}
代码示例来源:origin: reactor/reactor-core
LOGGER.warn("Attempting to activate metrics but the upstream is not Scannable. " +
"You might want to use `name()` (and optionally `tags()`) right before `metrics()`");
name = REACTOR_DEFAULT_NAME;
代码示例来源:origin: reactor/reactor-core
/**
* Structured logging with level adaptation and operator ascii graph if required.
*
* @param signalType the type of signal being logged
* @param signalValue the value for the signal (use empty string if not required)
*/
void log(SignalType signalType, Object signalValue) {
String line = fuseable ? LOG_TEMPLATE_FUSEABLE : LOG_TEMPLATE;
if (operatorLine != null) {
line = line + " " + operatorLine;
}
if (level == Level.FINEST) {
log.trace(line, signalType, signalValue);
}
else if (level == Level.FINE) {
log.debug(line, signalType, signalValue);
}
else if (level == Level.INFO) {
log.info(line, signalType, signalValue);
}
else if (level == Level.WARNING) {
log.warn(line, signalType, signalValue);
}
else if (level == Level.SEVERE) {
log.error(line, signalType, signalValue);
}
}
代码示例来源:origin: reactor/reactor-core
private void demonstrateLogError() {
Loggers.getLogger("logError.default")
.warn("The following logs should demonstrate similar error output, but respectively at ERROR, DEBUG and TRACE levels");
Mono<Object> error = Mono.error(new IllegalStateException("boom"));
error.log("logError.default")
.subscribe(v -> {}, e -> {});
error.log("logError.fine", Level.FINE)
.subscribe(v -> {}, e -> {});
error.log("logError.finest", Level.FINEST)
.subscribe(v -> {}, e -> {});
}
代码示例来源:origin: io.projectreactor/reactor-core
@Override
public void onError(Throwable e) {
Loggers.getLogger(FluxUsingWhen.class).warn("Async resource cleanup failed after cancel", e);
}
代码示例来源:origin: reactor/reactor-netty
@Override
public void onUncaughtException(Connection connection, Throwable error) {
if (error instanceof RedirectClientException && log.isDebugEnabled()) {
log.debug(format(connection.channel(), "The request will be redirected"));
}
else if (AbortedException.isConnectionReset(error) && log.isDebugEnabled()) {
log.debug(format(connection.channel(), "The connection observed an error, " +
"the request will be retried"), error);
}
else {
log.warn(format(connection.channel(), "The connection observed an error"), error);
}
sink.error(error);
}
内容来源于网络,如有侵权,请联系作者删除!