Class MockLoggerFactory

java.lang.Object
io.micrometer.core.util.internal.logging.InternalLoggerFactory
io.micrometer.core.util.internal.logging.MockLoggerFactory

@Deprecated public class MockLoggerFactory extends io.micrometer.core.util.internal.logging.InternalLoggerFactory
Deprecated.
Please use MockLoggerFactory instead.
Simple InternalLoggerFactory implementation that always returns an instance of MockLogger so components that fetch the logger this way: InternalLogger logger = InternalLoggerFactory.getInstance(MyClass.class);, get a MockLogger instance if they are created using factory.injectLogger(MyClass::new) or if InternalLoggerFactory.setDefaultFactory(mockLoggerFactory); was set previously.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getLogger(Class<?> clazz)
    Deprecated.
    A convenient way to create a logger.
    Deprecated.
    A convenient way to create a logger.
    <T> T
    injectLogger(Supplier<T> supplier)
    Deprecated.
    A factory method that returns the result of the given Supplier and also injects the default factory.
    protected io.micrometer.core.util.internal.logging.InternalLogger
    Deprecated.
     

    Methods inherited from class io.micrometer.core.util.internal.logging.InternalLoggerFactory

    getDefaultFactory, getInstance, getInstance, setDefaultFactory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MockLoggerFactory

      public MockLoggerFactory()
      Deprecated.
  • Method Details

    • getLogger

      public MockLogger getLogger(Class<?> clazz)
      Deprecated.
      A convenient way to create a logger. In contrast of InternalLoggerFactory.getInstance(Class), this method returns a MockLogger instead of an InternalLoggerFactory so that you don't need to cast.
      Parameters:
      clazz - The class that you need the logger for.
      Returns:
      An instance of MockLogger for the provided class.
    • getLogger

      public MockLogger getLogger(String name)
      Deprecated.
      A convenient way to create a logger. In contrast of InternalLoggerFactory.getInstance(String), this method returns a MockLogger instead of an InternalLoggerFactory so that you don't need to cast.
      Parameters:
      name - The name of the logger.
      Returns:
      An instance of MockLogger for the provided name.
    • injectLogger

      public <T> T injectLogger(Supplier<T> supplier)
      Deprecated.
      A factory method that returns the result of the given Supplier and also injects the default factory. So if the logger is created this way: InternalLogger logger = InternalLoggerFactory.getInstance(MyClass.class);, the resulted logger will be a MockLogger.

      NOTE: This doesn't work when a target logger is a static field and has been initialized already. Use a non-static field for a target logger to make this work consistently.

      Type Parameters:
      T - The type of an object that will be created by the Supplier.
      Parameters:
      supplier - The logic that creates the object you need to inject the logger into.
      Returns:
      The result of the Supplier.
    • newInstance

      protected io.micrometer.core.util.internal.logging.InternalLogger newInstance(String name)
      Deprecated.
      Specified by:
      newInstance in class io.micrometer.core.util.internal.logging.InternalLoggerFactory