Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.99k stars 573 forks source link

String formatting and print(f) #7395

Open dnsmichi opened 5 years ago

dnsmichi commented 5 years ago

Describe the solution you'd like

User-friendly support for formatting strings based on specific format patterns. Independent from the value type, printf style, or Python style - common to the users.

A Printing class as entry point for:

Creating a custom solution is a no-go, we'll need to evaluate possible candidates out there. Header only includes are preferred.

Related Issues

Describe alternatives you've considered

https://github.com/fmtlib/fmt will be the base for C++ 20's std::format implementation. Therefore it is safe to assume we can be use it and later convert to the standard library if needed.

http://www.zverovich.net/2019/07/23/std-format-cpp20.html

If we consider replacing our logging library, spdlog also uses fmt under the hood. https://github.com/gabime/spdlog

Benchmarks

dnsmichi commented 5 years ago

@htriem Please evaluate the library fmt during the coming weeks, when you got time.

Once done, continue with the integration into Icinga 2:

Logging

dnsmichi commented 5 years ago

Header only: https://github.com/fmtlib/fmt/issues/596#issuecomment-341617817

#define FMT_HEADER_ONLY
#include "fmt/format.h"
htriem commented 4 years ago

Looks like this is more complicated to implement inside the DSL. We need to find a way to map a list of array items from fmt to the Icinga DSL. Therefore TBD.

julianbrost commented 3 years ago

Is there a real need for this? Sure, would be nice to have but this has been lying around for some time with no progress, so maybe wontfix for the foreseeable future?

Al2Klimov commented 2 years ago

@htriem You're not working on this, right?

htriem commented 2 years ago

Not currently, no.