Logging Tooltip Extension >

Logging Tooltip Customisation

The Logging Tooltip extension can be customised using a ConcordionExtensionFactory to restrict the log output to named loggers, and by logging level. The output of logging to the console can also be enabled.

Example - restrict output to single named logger

Given the LoggingTooltipExtensionFactory has been restricted to use only the foo logger,

and the system property concordion.extensions is set to the class spec.concordion.ext.loggingTooltip.LoggingTooltipExtensionFactory.

When running

<p concordion:assertEquals="getName()">Frank</p>

with a fixture that logs "Hello Foo" to the foo logger, and "Hello Bar" to the bar logger, the logging tooltip displays: 

i [10:25:28.229]: Hello Foo
[10:25:28.230]: Hello Bar
[10:25:28.230]: Hello Baz
[10:25:28.231]: Failed to generate breadcrumb
[timestamp]: Hello Foo

Example - restrict output to multiple named loggers

Given the LoggingTooltipExtensionFactory has been restricted to use the baz, foo loggers,

and the system property concordion.extensions is set to the class spec.concordion.ext.loggingTooltip.LoggingTooltipExtensionFactory.

When running

<p concordion:assertEquals="getName()">Frank</p>

with a fixture that logs "Hello Foo" to the foo logger, "Hello Bar" to the bar logger, and "Hello Baz" to the baz logger, the logging tooltip displays: 

i [10:25:28.251]: Hello Foo
[10:25:28.252]: Hello Bar
[10:25:28.252]: Hello Baz
[10:25:28.254]: Failed to generate breadcrumb
[timestamp]: Hello Foo
[timestamp]: Hello Baz

Example - restrict output to specific log level

Given the LoggingTooltipExtensionFactory has been restricted to use the INFO log level,

and the system property concordion.extensions is set to the class spec.concordion.ext.loggingTooltip.LoggingTooltipExtensionFactory.

When running

<p concordion:execute="logStuff()"/>

with a fixture that logs "Hello Info" at the INFO log level, "Hello Fine" to the FINE log level, and "Hello Warn" to the WARN log level, the logging tooltip displays: 

i [10:25:28.268]: Hello Info
[10:25:28.269]: Hello Warn
[10:25:28.270]: Failed to generate breadcrumb
[timestamp]: Hello Info
[timestamp]: Hello Warn

For those not using java.util.logging, a custom LogMessenger can be provided. For the sake of the below example, the implementation is one that returns a fixed string, but alternatives that use Logback, log4j or slf4j can be easily implemented as an exercise for the reader.

Example - custom log messenger

Given the AlternateLoggingTooltipExtensionFactory has been told to return Hello AlternateLoggingTooltipExtensionFactory as a log message,

and the system property concordion.extensions is set to the class spec.concordion.ext.loggingTooltip.AlternateLoggingTooltipExtensionFactory.

When running

<p concordion:execute="logStuff()"/>

the logging tooltip displays: 

i [10:25:28.290]: Hello Info
[10:25:28.292]: Hello Warn
[10:25:28.294]: Failed to generate breadcrumb
[timestamp]: Hello AlternateLoggingTooltipExtensionFactory