Tabnine Logo
LoggingHandler.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.springframework.integration.handler.LoggingHandler
constructor

Best Java code snippets using org.springframework.integration.handler.LoggingHandler.<init> (Showing top 11 results out of 315)

origin: spring-projects/spring-integration

@Bean
public MessageHandler loggingMessageHandler() {
  return new LoggingHandler(LoggingHandler.Level.DEBUG);
}
origin: spring-projects/spring-integration

@Test
public void testChangeLevel() {
  LoggingHandler loggingHandler = new LoggingHandler(Level.INFO);
  loggingHandler.setBeanFactory(mock(BeanFactory.class));
  loggingHandler.afterPropertiesSet();
  DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
  Log log = (Log) accessor.getPropertyValue("messageLogger");
  log = spy(log);
  accessor.setPropertyValue("messageLogger", log);
  when(log.isInfoEnabled()).thenReturn(true);
  loggingHandler.handleMessage(new GenericMessage<>("foo"));
  verify(log, times(1)).info(Mockito.anyString());
  verify(log, never()).warn(Mockito.anyString());
  loggingHandler.setLevel(Level.WARN);
  loggingHandler.handleMessage(new GenericMessage<>("foo"));
  verify(log, times(1)).info(Mockito.anyString());
  verify(log, times(1)).warn(Mockito.anyString());
}
origin: spring-projects/spring-integration

@Test
public void testDontEvaluateIfNotEnabled() {
  LoggingHandler loggingHandler = new LoggingHandler("INFO");
  loggingHandler.setBeanFactory(mock(BeanFactory.class));
  loggingHandler.afterPropertiesSet();
  DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
  Log log = (Log) accessor.getPropertyValue("messageLogger");
  log = spy(log);
  accessor.setPropertyValue("messageLogger", log);
  Expression expression = (Expression) accessor.getPropertyValue("expression");
  expression = spy(expression);
  accessor.setPropertyValue("expression", expression);
  when(log.isInfoEnabled()).thenReturn(false);
  loggingHandler.handleMessage(new GenericMessage<>("foo"));
  verify(expression, never()).getValue(Mockito.any(EvaluationContext.class), Mockito.any(Message.class));
  when(log.isInfoEnabled()).thenReturn(true);
  loggingHandler.handleMessage(new GenericMessage<>("foo"));
  verify(expression, times(1)).getValue(Mockito.any(EvaluationContext.class), Mockito.any(Message.class));
}
origin: spring-projects/spring-integration

/**
 * Populate a {@link WireTap} for the {@link #currentMessageChannel}
 * with the {@link LoggingHandler} subscriber for the provided
 * {@link LoggingHandler.Level} logging level, logging category
 * and SpEL expression for the log message.
 * <p> When this operator is used in the end of flow, it is treated
 * as one-way handler without any replies to continue.
 * The {@link #logAndReply()} should be used for request-reply configuration.
 * @param level the {@link LoggingHandler.Level}.
 * @param category the logging category.
 * @param logExpression the {@link Expression} to evaluate logger message at runtime
 * against the request {@link Message}.
 * @return the current {@link IntegrationFlowDefinition}.
 * @see #wireTap(WireTapSpec)
 */
public B log(LoggingHandler.Level level, String category, Expression logExpression) {
  LoggingHandler loggingHandler = new LoggingHandler(level);
  if (StringUtils.hasText(category)) {
    loggingHandler.setLoggerName(category);
  }
  if (logExpression != null) {
    loggingHandler.setLogExpression(logExpression);
  }
  else {
    loggingHandler.setShouldLogFullMessage(true);
  }
  addComponent(loggingHandler);
  MessageChannel loggerChannel = new FixedSubscriberChannel(loggingHandler);
  return wireTap(loggerChannel);
}
origin: spring-projects/spring-integration

@Test
public void testUsageWithoutSpringInitialization() {
  LoggingHandler loggingHandler = new LoggingHandler("ERROR");
  DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
  Log log = (Log) accessor.getPropertyValue("messageLogger");
  log = spy(log);
  accessor.setPropertyValue("messageLogger", log);
  String testPayload = "TEST_PAYLOAD";
  Message<String> message = MessageBuilder.withPayload(testPayload).build();
  loggingHandler.handleMessage(message);
  verify(log).error(testPayload);
}
origin: spring-projects/spring-integration

@Test
public void assertMutuallyExclusive() {
  LoggingHandler loggingHandler = new LoggingHandler("INFO");
  loggingHandler.setLogExpressionString("'foo'");
  try {
    loggingHandler.setShouldLogFullMessage(true);
    fail("Expected IllegalArgumentException");
  }
  catch (IllegalArgumentException e) {
    assertEquals("Cannot set both 'expression' AND 'shouldLogFullMessage' properties", e.getMessage());
  }
  loggingHandler = new LoggingHandler("INFO");
  loggingHandler.setShouldLogFullMessage(true);
  try {
    loggingHandler.setLogExpressionString("'foo'");
    fail("Expected IllegalArgumentException");
  }
  catch (IllegalArgumentException e) {
    assertEquals("Cannot set both 'expression' AND 'shouldLogFullMessage' properties", e.getMessage());
  }
}
origin: spring-projects/spring-integration

@Override
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) {
  LoggingHandler.Level level = MessagingAnnotationUtils.resolveAttribute(annotations, "level",
      LoggingHandler.Level.class);
  LoggingHandler loggingHandler = new LoggingHandler(level.name());
  MethodInvokingMessageProcessor<String> processor = new MethodInvokingMessageProcessor<>(bean, method);
  processor.setBeanFactory(this.beanFactory);
  loggingHandler.setLogExpression(new FunctionExpression<>(processor::processMessage));
  return loggingHandler;
}
origin: spring-cloud/spring-cloud-stream-app-starters

@Bean
@ServiceActivator(inputChannel = Sink.INPUT)
public LoggingHandler logSinkHandler() {
  LoggingHandler loggingHandler = new LoggingHandler(this.properties.getLevel().name());
  loggingHandler.setExpression(this.properties.getExpression());
  loggingHandler.setLoggerName(this.properties.getName());
  return loggingHandler;
}
origin: spring-projects/spring-integration-java-dsl

/**
 * Populate a {@link WireTap} for the {@link #currentMessageChannel}
 * with the {@link LoggingHandler} subscriber for the provided
 * {@link LoggingHandler.Level} logging level, logging category
 * and SpEL expression for the log message.
 * @param level the {@link LoggingHandler.Level}.
 * @param category the logging category.
 * @param logExpression the {@link Expression} to evaluate logger message at runtime
 * against the request {@link Message}.
 * @return the current {@link IntegrationFlowDefinition}.
 * @since 1.2
 */
public B log(LoggingHandler.Level level, String category, Expression logExpression) {
  LoggingHandler loggingHandler = new LoggingHandler(level);
  if (StringUtils.hasText(category)) {
    loggingHandler.setLoggerName(category);
  }
  if (logExpression != null) {
    loggingHandler.setLogExpression(logExpression);
  }
  else {
    loggingHandler.setShouldLogFullMessage(true);
  }
  addComponent(loggingHandler);
  MessageChannel loggerChannel = new FixedSubscriberChannel(loggingHandler);
  return wireTap(loggerChannel);
}
origin: org.springframework.integration/spring-integration-core

/**
 * Populate a {@link WireTap} for the {@link #currentMessageChannel}
 * with the {@link LoggingHandler} subscriber for the provided
 * {@link LoggingHandler.Level} logging level, logging category
 * and SpEL expression for the log message.
 * <p> When this operator is used in the end of flow, it is treated
 * as one-way handler without any replies to continue.
 * The {@link #logAndReply()} should be used for request-reply configuration.
 * @param level the {@link LoggingHandler.Level}.
 * @param category the logging category.
 * @param logExpression the {@link Expression} to evaluate logger message at runtime
 * against the request {@link Message}.
 * @return the current {@link IntegrationFlowDefinition}.
 * @see #wireTap(WireTapSpec)
 */
public B log(LoggingHandler.Level level, String category, Expression logExpression) {
  LoggingHandler loggingHandler = new LoggingHandler(level);
  if (StringUtils.hasText(category)) {
    loggingHandler.setLoggerName(category);
  }
  if (logExpression != null) {
    loggingHandler.setLogExpression(logExpression);
  }
  else {
    loggingHandler.setShouldLogFullMessage(true);
  }
  addComponent(loggingHandler);
  MessageChannel loggerChannel = new FixedSubscriberChannel(loggingHandler);
  return wireTap(loggerChannel);
}
origin: org.springframework.integration/spring-integration-java-dsl

/**
 * Populate a {@link WireTap} for the {@link #currentMessageChannel}
 * with the {@link LoggingHandler} subscriber for the provided
 * {@link LoggingHandler.Level} logging level, logging category
 * and SpEL expression for the log message.
 * @param level the {@link LoggingHandler.Level}.
 * @param category the logging category.
 * @param logExpression the {@link Expression} to evaluate logger message at runtime
 * against the request {@link Message}.
 * @return the current {@link IntegrationFlowDefinition}.
 * @since 1.2
 */
public B log(LoggingHandler.Level level, String category, Expression logExpression) {
  LoggingHandler loggingHandler = new LoggingHandler(level);
  if (StringUtils.hasText(category)) {
    loggingHandler.setLoggerName(category);
  }
  if (logExpression != null) {
    loggingHandler.setLogExpression(logExpression);
  }
  else {
    loggingHandler.setShouldLogFullMessage(true);
  }
  addComponent(loggingHandler);
  MessageChannel loggerChannel = new FixedSubscriberChannel(loggingHandler);
  return wireTap(loggerChannel);
}
org.springframework.integration.handlerLoggingHandler<init>

Javadoc

Create a LoggingHandler with the given log level (case-insensitive).

The valid levels are: FATAL, ERROR, WARN, INFO, DEBUG, or TRACE

Popular methods of LoggingHandler

  • setLogExpression
    Set an Expression to evaluate a log entry at runtime against the request Message.
  • setLoggerName
  • setShouldLogFullMessage
    Specify whether to log the full Message. Otherwise, only the payload will be logged. This value isfa
  • convertLevel
  • createLogMessage
  • doSetLevel
  • getBeanFactory
  • printStackTrace
  • setLogExpressionString
    Set a SpEL expression string to use.
  • afterPropertiesSet
  • handleMessage
  • handleMessageInternal
  • handleMessage,
  • handleMessageInternal,
  • setBeanFactory,
  • setExpression,
  • setLevel

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now