diff options
author | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2024-05-30 21:48:06 +0300 |
---|---|---|
committer | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2024-05-30 21:57:42 +0300 |
commit | d6adb2d70464c9eb08b2b24076be43c44d5a8b74 (patch) | |
tree | fca4b31583b00c5d3a17d114a9923b67e72745ed /contrib/python/chardet/py2/README.rst | |
parent | b5530daab1ea3757321436470f86ed65f30408c9 (diff) | |
download | ydb-d6adb2d70464c9eb08b2b24076be43c44d5a8b74.tar.gz |
YT-21868: Static analysis of format string in logging
Added static analysis to format of YT_LOG_XXX macro's. We expect you to write format string as first or the second argument and follow the rules as if you are writing arguments for `NYT::Format`, which match those of printf: https://en.cppreference.com/w/cpp/io/c/fprintf plus few extra flags like 'v'. At the moment analyser checks if flags sequences is
1. Correctly terminated
2. Only contains specifiers valid for a given argument (if we are parsing nth argument of type T, then T must have all specifiers from its list of Conversion or Flag specifiers.
(2) Also means that the number of flag sequences must match the number of arguments supplied to format.
You can specialize `TFormatArg<T>` which is used to determine allowed Conversion and Flag specifiers to customise rules of static analysis. E.g. you can introduce new flags to the mix which you promise to parse in the related FormatValue function.
If you feel like this produces to much overhead in terms of compile time, you are free to use macro YT_DISABLE_FORMAT_STATIC_ANALYSIS to turn the entire thing into a no-op. We have measured compile time to be affected by roughly 3-5% in a log intensive files.
ae6def509474e8a42027bb4ed84ac040509b7c85
Diffstat (limited to 'contrib/python/chardet/py2/README.rst')
0 files changed, 0 insertions, 0 deletions