In order to trace and track Flex script action execution it can be useful to add logging statements. The is done via the provided `context` object:
def execute() {
context.logInfo('This is an information message');
context.logWarn('Indicates that something unexpected occurred, but one that is not fatal');
context.logError('Indicates that an unrecoverable error has occured');
}
Calling these log methods results in events been raised against the job, which can be viewed on the job's history tab. `info` level logs will be deleted automatically after 14 days. Note that in Flex versions before 2021.10.0, calls to `context.logInfo` would not be raised as events, but rather logged to the standard Flex logging infrastructure, visible via Kibana
Placeholders
When creating log messages you can use placeholders to keep the messages easy to read:
content.logInfo('The asset ID is {}', asset.id);
content.logError('{} assets returned when expecting {}', assets.size, expectedSize);
You can also use Groovy templated strings:
content.logInfo("The asset ID is ${asset.id}")
Comments
0 comments
Please sign in to leave a comment.