#I created a logger class to use in all my projects

1 messages · Page 1 of 1 (latest)

lusty citrus
#

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.

vague hill
#

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

random locust
#

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.

lusty citrus
#

@random locust I am using CMake. Separating makes sense

lusty citrus
lusty citrus
random locust
#

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"

#

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.

lusty citrus
#

@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

sweet torrent
#

just at a glance, std::source_location exists