Class TransportLogger
- java.lang.Object
-
- de.iip_ecosphere.platform.services.environment.TransportLogger
-
public class TransportLogger extends java.lang.ObjectLogs transport messages for debugging. Must be executed within an environment where a- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransportLogger.CategoryThe output data category.protected static classTransportLogger.TransportHandler<T>Implements a generic transport handler for logging.
-
Field Summary
Fields Modifier and Type Field Description private static de.iip_ecosphere.platform.transport.connectors.TransportConnectorconnprivate static java.io.PrintStreamfileOutprivate static java.util.Map<java.lang.String,TransportLogger.TransportHandler<?>>handlersprivate static java.util.function.Supplier<java.lang.Boolean>loopEndSupplierprivate static java.util.function.BiConsumer<TransportLogger.Category,java.lang.String>receptionConsumerprivate static EnvironmentSetupsetupprivate static java.util.function.Consumer<EnvironmentSetup>setupCustomizerprivate static java.lang.RunnableshutdownRunnable
-
Constructor Summary
Constructors Constructor Description TransportLogger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidaddHandler(java.lang.String arg, TransportLogger.TransportHandler<?> handler)Adds a transport handler.protected static <T> voidaddHandler(java.lang.String arg, java.lang.String stream, java.lang.Class<T> cls, java.util.function.Consumer<T> cons)Adds a transport handler.private static voidlog(TransportLogger.Category category, java.lang.String text)Logs the output.static voidmain(java.lang.String[] args)Starts the transport logger.static voidsetLoopEndSupplier(java.util.function.Supplier<java.lang.Boolean> supplier)Defines an optional loop end supplier (default constanttrue).static voidsetReceptionConsumer(java.util.function.BiConsumer<TransportLogger.Category,java.lang.String> consumer)Defines an optional consumer to be called on data reception.static voidsetSetupCustomizer(java.util.function.Consumer<EnvironmentSetup> customizer)Defines the setup customizer.static voidsetShutdownRunnable(java.lang.Runnable runnable)Changes the default shutdown runnable.static voidshutdown()Shuts down this logger and disconnects fromTransport.protected static java.lang.StringtoString(java.lang.Object obj)Generic toString method.
-
-
-
Field Detail
-
setup
private static EnvironmentSetup setup
-
conn
private static de.iip_ecosphere.platform.transport.connectors.TransportConnector conn
-
handlers
private static java.util.Map<java.lang.String,TransportLogger.TransportHandler<?>> handlers
-
setupCustomizer
private static java.util.function.Consumer<EnvironmentSetup> setupCustomizer
-
receptionConsumer
private static java.util.function.BiConsumer<TransportLogger.Category,java.lang.String> receptionConsumer
-
loopEndSupplier
private static java.util.function.Supplier<java.lang.Boolean> loopEndSupplier
-
shutdownRunnable
private static java.lang.Runnable shutdownRunnable
-
fileOut
private static java.io.PrintStream fileOut
-
-
Method Detail
-
addHandler
protected static void addHandler(java.lang.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(java.lang.String arg, java.lang.String stream, java.lang.Class<T> cls, java.util.function.Consumer<T> cons)Adds a transport handler.- Type Parameters:
T- the type to be handled- Parameters:
arg- the argument name to activate the handlerstream- the stream to handlecls- the data type onstreamto handlecons- the consumer for received data
-
toString
protected static java.lang.String toString(java.lang.Object obj)
Generic toString method.- Parameters:
obj- the object to be turned into a string- Returns:
- the formatted string
-
setSetupCustomizer
public static void setSetupCustomizer(java.util.function.Consumer<EnvironmentSetup> customizer)
Defines the setup customizer. [testing]- Parameters:
customizer- the customizer, ignored if null
-
setReceptionConsumer
public static void setReceptionConsumer(java.util.function.BiConsumer<TransportLogger.Category,java.lang.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(java.lang.Runnable runnable)
Changes the default shutdown runnable. [testing]- Parameters:
runnable- the runnable, ignored if null
-
setLoopEndSupplier
public static void setLoopEndSupplier(java.util.function.Supplier<java.lang.Boolean> supplier)
Defines an optional loop end supplier (default constanttrue). [testing]- Parameters:
supplier- the supplier, ignored if null
-
log
private static void log(TransportLogger.Category category, java.lang.String text)
Logs the output.- Parameters:
category- the data categorytext- the text representing the data
-
main
public static void main(java.lang.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 thesetupFile.- 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 fromTransport. [testing]
-
-