There are tons of logger libraries for C++ available. But all comes with its own complexities and bloating. I want a simple logger which can print seamlessly in multithreading. This is not perfect but I intend to clean it up as I use it. Here is the repo link https://github.com/Ananthsada/SadaLogger. Please review the code. There are definitely a lot of things to improve. Please suggest.
#I created a logger class to use in all my projects
1 messages · Page 1 of 1 (latest)
looks ok to me generally
I would recommend using early return or early continue
to not nest code too much
I think std::scoped_lock is nowadays the way to go
you can use std::string_view instead of const std::string& if you have C++17
Looks hard to include in other projects. Maybe use cmake?
I think at the very least, you should separate your include files into a different folder than your source files.
@random locust I am using CMake. Separating makes sense
okay
I haven't used it yet. I will try it Thanks
Yes, I am using C++17. I am not sure what is the advantage of std::string_view over std::string. Thanks for the comment. I will explore a bit
Wow I missed it idk why. Maybe use target_sources instead of storing your sources in a variable
In modern CMake, its generally better to store stuff in targets over variables. less of a mess
For your testing, why don't you use a test framework such as catch2
you can automatically run the tests every time you commit on github using github actions. its not hard
I do that in the project I linked
You can easily fetch third party sources such as catch2 using the CMake command "FetchContent"
Another idea: use the REUSE specification for your licensing. https://reuse.software/spec/
I do it in all of my projects including the one I linked
REUSE is used for many big time open source projects like the linux kernel and curl
The best thing to do for an open source library that uses CMake is to add an installation target. This makes it a lot easier for people to use your library in their own projects.
@random locust Great, Thanks for the nice suggestions. I am exploring catch2 now ✌️
I thought of integrating gtest which I already have some experience with. I will surely explore. Thanks