Skip to content

Delegate formatting of log messages to the logger

Pavel Kisliak requested to merge epam/uniform_logging_style3 into main

Type of change

  • Bug Fix
  • Feature

Does this introduce a change in the core logic?

  • [No]

Does this introduce a change in the cloud provider implementation, if so which cloud?

  • AWS
  • Azure
  • GCP
  • IBM

Updates description?

Second part of work on uniform logging style (issue: #53 (closed))
This MR will enable formatting without explicit usages of fmt::format library:

OES_ERROR("Cannot determine server port: {}\n", ec.message());

Additionally this will solve issue with unexpected exceptions when formatting log messages.

  • Add internal formatting to oes::core::Logger (based on fmt library).
  • Remove all explicit usages of fmt::format() from logging.
  • Improve logging safety (handles exceptions on formatting issues).
  • Few other optimizations in the logger like usages of std::string_view for store file and function.
  • Include directives for 3rd-party libraries was moved to top (logger requires to have explicitly included fmt library).

Important notes:

Used approach with SFINAE allows to not make explicit dependency from fmt library, formatting will be enabled only if you have included fmt.
Logging can can be continued used in the header files (without fmt dependency), but with only plain text messages.
If you will try to use formatted logging without fmt, you will get compilation error:

Logging messages with formatting is only allowed with the `fmt` library (did you forget to include it?)

Merge request reports

Loading