-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use custom namespace for bundled libfmt (#315)
* add missing header to file * rename libfmt namespace and macros * use custom namespace for bundled libfmt * use custom namespace for bundled libfmt * fix tests
- Loading branch information
Showing
41 changed files
with
1,830 additions
and
1,759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
c580d49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @odygrd !
I am working on a logging library in C++, I built my implementation upon Glaze C++ logging library, that uses the Format library. I had a working code, but I think, after refreshing my cmakelists file, which has glaze, and quill (quill has fmt) as fetchcontent, my quill and fmt related macros stopped working. I checked the repositories commit history, and seen some changes inside the quill library that might affected something on my end. I am talking about the last 5 commits, or around that. I am saying this because I downloaded one of my older working commits from git, and was not able to run that either.
This is the line that gives the errors. For my own type to be loggable I followed quills and fmts instructions and made changes accordingly (glz => copyable object, fmt => specialized formatter):
This alone, was enough for me previously to log my own Trade_data objects without any problems, but right now I get a lot of errors.
bundled/fmt/core.h related problems and use of deleted function ‘fmtquill::v10::formatter<T, Char, Enable>::formatter() [with T = Trade_data; Char = char; Enable = void]’
2529 | return formatter<mapped_type, char_type>().parse(ctx);
bundled/fmt/core.h:1071:3: note: declared here
1071 | formatter() = delete;
bundled/fmt/core.h:2638:27: error: ‘constexpr’ call flows off the end of the function
2638 | FMTQUILL_CONSTEXPR bool error = (parse_format_string(s, checker(s)), true);
bundled/fmt/core.h:1566:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#udt
1566 | formattable,
| ^~~~~~~~~~~
Could these errors be caused be my local and quill librarys fmt library installation and dependecy?
Thank you for your time!
c580d49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bundled fmt library namespace got renamed. It used to work fine when your installed fmt library was the same version as the bundled one. But if they are different versions it could previously cause you problems.
when using the bundled one you now have to use
struct fmtquill::formatter for the logger to see it
quill/examples/example_user_defined_types.cpp
Line 28 in c580d49
if you’re using quill’s bundled fmt across your whole project you need to use namespace fmtquill or create a namespace alias
namespace fmt = fmtquill
The other option if you don’t wish to rename those is to build using your system installed fmt library if you have one
quill/quill/include/quill/TweakMe.h
Line 182 in c580d49
quill/CMakeLists.txt
Line 8 in c580d49
c580d49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @odygrd !
I have done the first thing that you suggested. I modified my code, added the fmtquill::formatter and an overloaded << operator as well:
With this, I am able to log Trade_data type objects. But I had to change the Trade_data classes code for it to work, by overriding the << operator. If I would like to be able to log not user defined types, how could I achive that without changing those underlying classes?
Previously providing a fmt::formatter for them as well was enough, but I dont know what to implement override in the fmtquill::formatter case.
But when I want to log a glz::obj type, these are the error messages:
quillMongo/main.cpp:48:9: required from here
quillMongo/cmake-build-debug/_deps/quill-src/quill/include/quill/bundled/fmt/ostream.h:97:10: error: no match for ‘operator<<’
97 | output << value;
| ~~~~~~~^~~~~~~~
Is there any other way to log user defined types other, than overriding the << operator ? Because if I needed any private members of those classes I would not be able to access them.
After defining an overloaded << operator it works:
And by writing just the "{}" signs LOG_INFO(logger_bar, "{}", Trade_data(...)); logging of user defined data would work?
c580d49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't want to overload operator<< then you don't need to define
because the reason you define this is to enable formatting via
operator<<
You can instead use your own
fmt
formatter for example if you are using the bundled fmtquill :Also see
Everything is exactly the same as in the above documentation, the only difference is that you need to use namespace
fmtquill
instead offmt
when you are using the bundled fmt libraryLet me know if that works for you
c580d49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @odygrd !
I tried out your solution and it worked! Thank you for your help with figuring out this issue.