Skip to content

Improve logging system

Favero requested to merge feature-logjson into develop

Hello Robert, I would like to push this improvement related to the logging system. The logging library of RAN part has been modified to be able to improve automation of log processing and default logging to file sink instead of console. Complementary information can be found in this ticket that tracks also the tests I performed.

Features added

  1. JSON formatting

Logs have been structured in a unified machine-oriented format to allow for an easier logs processing automation in the log management subsystem. It has been chosen JSON (i.e. over XML) for simplicity and compactness. Its format brings also extensibility in mind: for example adding a new field in the output string in the future will be easy from development point of view and log analysis one.

Example of output:

  • with legacy formatting: [PHY] test_log_discarded_options.
  • with json feature activated: { DateTime: "2022-05-25T14:33:21+00.00", ServiceName: "PHY", Severity: "I", Data: "test_log_discarded_options"}.

The implementation will provide a breaking change when activated. I envision rollout at API level for this feature via a feature flag compiling option OAI_LOG_JSON set explicitly by developer when building the log library, followed by one month grace period to pass to default activation and a further one month before removal of the previous code. Give the possibility to the user to tune the format of the output will drop the advantages that come from one structured machine oriented format (JSON). Just the choice to enable the correlation_id field in the formatting output will be left to the user to prevent performance issues in case cross event correlation functionality is not needed at log management subsystem.

  1. Log file rotation capability

It has been implemented the possibility to have size and age limits for the logfiles. This will prevent filling up the harddisk in case the files grow too much in size. This is activated by the user with a new option in the configuration file: global_log_rotation_size and global_log_rotation_time. By default it is deactivated. File logexample.conf in the source code contains some examples of usage.

  1. Unit tests pick-up

build_oai has been modified to be able to compile the unit tests for log API without introducing a new option. Development has been done to be less invasive as possible to not break the CI scripts. New command line usage: build_oai [options] [name of the target], previous build_oai [options]. This change has not been yet advertised in the commandline manual of build_oai as it has no impact on previous command lines and can also be considered to be removed by this merge request if deemed unnecessary.

Code quality

  • improved log library documentation in the log interface log.h .
  • added unit tests for the log library for the scope of points 1 and 2. It leverages Boost Test
  • changed function signature for some log api functions to be able to report errors.
  • astyle has been used to format the modified code
  • various tests have been performed to validate non regression, see https://gitlab.eurecom.fr/favero/newcomer/-/issues/2#note_54888

Impact analysis

See ticket associated https://gitlab.eurecom.fr/favero/newcomer/-/issues/2#note_54888

Thanks for your comments.

Merge request reports