In this post, I will show another change to our Shared Library, as expected, this library must be incremental.

Info

The codes, already complete, and the example pipeline are in our Git.
https://github.com/faustobranco/devops-db/tree/master/infrastructure/pipelines/lib-utilities

At this point, I created another classpath with some classes to use as Log message generators. So, whether in other classes / methods or within pipeline scripts, Log messages can always be standardized.

This classpath has a class with some constants, another to create an instance with the message formatting standards and the last with the calls to “print” the log.

The LogFormatter class, responsible for instantiating an object with the message formatting standards, has a constructor with the following information:

ParameterDescription
logLevelOne of the options of the LogFormatterConstants class, which in values can be: debug, info, warning, error or none.
This parameter defines the maximum message level, with Debug being the highest and error being the lowest (none, suppresses messages). So, if this level is in info, only the info, warning and error messages will be logged, debug, as it is a higher level, should not appear.
loggerNameIt is informative, name of the entry that must appear in the Log, enter []. If the loggerName is empty (”), it will not be shown, not even the [] characters.
printDateBoolean, whether the date will be shown in the Log or not.
dateFormatFormat in which the date should be shown in the log, for example: “dd.MM.yyyy – HH:mm:ss.SSS”

The instantiation of the Logger class has the Context parameters (from the pipeline) and the LogFormatter object in its constructor.

A simple logger call example:

import devopsdb.log.LogFormatter
import devopsdb.log.LogFormatterConstants
import devopsdb.log.Logger

LogFormatter obj_FormatterPipeline = new LogFormatter(LogFormatterConstants.const_Info, 'GeneratePassword', false, '')
Logger obj_LogPipeline = new Logger(this, obj_FormatterPipeline)

obj_LogPipeline.info('Generating Password')


Result:
[INFO] [GeneratePassword] Generating Password

Info

The codes, already complete, and the example pipeline are in our Git.
https://github.com/faustobranco/devops-db/tree/master/infrastructure/pipelines/lib-utilities

This is the structure, for now, of the library:

As you can see in the codes in Git, I made the calls in two ways, one within the “CreateFolders” method in the “Utilities” class and the other directly in the pipeline script.

This is the example return from the pipeline (it’s also in git).