Class TransportLogger
java.lang.Object
de.iip_ecosphere.platform.services.environment.TransportLogger
Logs transport messages for debugging. Must be executed within an environment where a
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe output data category.protected static classImplements a generic transport handler for logging. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static de.iip_ecosphere.platform.transport.connectors.TransportConnectorprivate static PrintStreamprivate static Map<String, TransportLogger.TransportHandler<?>> private static BiConsumer<TransportLogger.Category, String> private static EnvironmentSetupprivate static Consumer<EnvironmentSetup> private static Runnable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidaddHandler(String arg, TransportLogger.TransportHandler<?> handler) Adds a transport handler.protected static <T> voidaddHandler(String arg, String stream, Class<T> cls, Consumer<T> cons) Adds a transport handler.private static voidlog(TransportLogger.Category category, String text) Logs the output.static voidStarts the transport logger.static voidsetLoopEndSupplier(Supplier<Boolean> supplier) Defines an optional loop end supplier (default constanttrue).static voidDefines an optional consumer to be called on data reception.static voidsetSetupCustomizer(Consumer<EnvironmentSetup> customizer) Defines the setup customizer.static voidsetShutdownRunnable(Runnable runnable) Changes the default shutdown runnable.static voidshutdown()Shuts down this logger and disconnects fromTransport.protected static StringGeneric toString method.
-
Field Details
-
setup
-
conn
private static de.iip_ecosphere.platform.transport.connectors.TransportConnector conn -
handlers
-
setupCustomizer
-
receptionConsumer
-
loopEndSupplier
-
shutdownRunnable
-
fileOut
-
-
Constructor Details
-
TransportLogger
public TransportLogger()
-
-
Method Details
-
addHandler
Adds a transport handler.- Parameters:
arg- the argument name to activate the handler (ignored if null)handler- the handler (ignored if null)
-
addHandler
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
Generic toString method.- Parameters:
obj- the object to be turned into a string- Returns:
- the formatted string
-
setSetupCustomizer
Defines the setup customizer. [testing]- Parameters:
customizer- the customizer, ignored if null
-
setReceptionConsumer
Defines an optional consumer to be called on data reception. [testing]- Parameters:
consumer- the consumer, may be null for none
-
setShutdownRunnable
Changes the default shutdown runnable. [testing]- Parameters:
runnable- the runnable, ignored if null
-
setLoopEndSupplier
Defines an optional loop end supplier (default constanttrue). [testing]- Parameters:
supplier- the supplier, ignored if null
-
log
Logs the output.- Parameters:
category- the data categorytext- the text representing the data
-
main
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]
-