m8ty-logging - m8ty Logging

To be able to log method calls, m8ty offers a corresponding annotation system.

The following annotations are available for this purpose:

@LogMethod

Logs only the method call.

Example output

INFO  eu.m8ty.logging.LoggingImpl.logMethodCalled 49 - [m8ty Logging] Method MockKeycloakController.token(..) has been called

@LogDuration

Logs the method and the time used for it.

Example output

INFO  eu.m8ty.logging.LoggingImpl.logExecutionTime 37 - [m8ty Logging] MockKeycloakController.token(..) execution took 72 ms

@LogMethodWithParams

Logs the method with parameters. These can still be skipped or obfuscated accordingly.

The following parameters are available to control the parameters:

ArgumentTypeDescription
logInputboolSwitch to activate or deactivate input parameter logging.
logOutputboolSwitch to activate or deactivate output parameter logging.
obfuscateParametersarrayArray of parameter names to obfuscate at input and output logging.
obfuscateParametersInputarrayArray of parameter names to obfuscate at input logging.
obfuscateParametersOutputarrayArray of parameter names to obfuscate at output logging.
skipParametersarrayArray of parameter names to skip for input and output logging.
skipParametersInputarrayArray of parameter names to skip for input logging.
skipParametersOutputarrayArray of parameter names to skip for output logging.

Example output (without arguments)

INFO  eu.m8ty.logging.LoggingImpl.logMethodResult 99 - [m8ty Logging] Results for {}:
{} MockKeycloakController.token(..) {
"headers" : { },
"body" : {
"token" : "eyJraWQiOiJrZX...."
},
"statusCodeValue" : 200,
"statusCode" : "OK"
}

Example output (with logOutput=false argument)

INFO  eu.m8ty.logging.LoggingImpl.logMethodParams 78 - [m8ty Logging] Input parameter for MockKeycloakController.token(..):[String userId]
"b846f572-6329-4ce3-a788-c005e72cba09";

Example output (with obfuscateParameters = ["token"] argument)

INFO  eu.m8ty.logging.LoggingImpl.logMethodResult 99 - [m8ty Logging] Results for {}:
{} MockKeycloakController.token(..) {
"headers" : { },
"body" : {
"token" : "*****"
},
"statusCodeValue" : 200,
"statusCode" : "OK"
}

Packages

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard