Class TransportLogger

java.lang.Object
de.iip_ecosphere.platform.services.environment.TransportLogger

public class TransportLogger extends Object
Logs transport messages for debugging. Must be executed within an environment where a
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • TransportLogger

      public TransportLogger()
  • Method Details

    • addHandler

      protected static void addHandler(String arg, TransportLogger.TransportHandler<?> handler)
      Adds a transport handler.
      Parameters:
      arg - the argument name to activate the handler (ignored if null)
      handler - the handler (ignored if null)
    • addHandler

      protected static <T> void addHandler(String arg, String stream, Class<T> cls, Consumer<T> cons)
      Adds a transport handler.
      Type Parameters:
      T - the type to be handled
      Parameters:
      arg - the argument name to activate the handler
      stream - the stream to handle
      cls - the data type on stream to handle
      cons - the consumer for received data
    • toString

      protected static String toString(Object obj)
      Generic toString method.
      Parameters:
      obj - the object to be turned into a string
      Returns:
      the formatted string
    • setSetupCustomizer

      public static void setSetupCustomizer(Consumer<EnvironmentSetup> customizer)
      Defines the setup customizer. [testing]
      Parameters:
      customizer - the customizer, ignored if null
    • setReceptionConsumer

      public static void setReceptionConsumer(BiConsumer<TransportLogger.Category,String> consumer)
      Defines an optional consumer to be called on data reception. [testing]
      Parameters:
      consumer - the consumer, may be null for none
    • setShutdownRunnable

      public static void setShutdownRunnable(Runnable runnable)
      Changes the default shutdown runnable. [testing]
      Parameters:
      runnable - the runnable, ignored if null
    • setLoopEndSupplier

      public static void setLoopEndSupplier(Supplier<Boolean> supplier)
      Defines an optional loop end supplier (default constant true). [testing]
      Parameters:
      supplier - the supplier, ignored if null
    • log

      private static void log(TransportLogger.Category category, String text)
      Logs the output.
      Parameters:
      category - the data category
      text - the text representing the data
    • main

      public static void main(String[] args)
      Starts the transport logger. Three default streams are taken into account, namely the optional service traces, the platform status and the platform monitoring metrics. By default, the setup is taken from the application's "application.yml", but on platform level it may be needed to define the setupFile.
      Parameters:
      args - command line arguments, e.g., --traces=true, --setupFile=iipecosphere.yml, --status=true, --metrics=true
    • shutdown

      public static void shutdown()
      Shuts down this logger and disconnects from Transport. [testing]