-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This section will provide the information needed to include SBLogger in your projects, either as source code or as a library.
Note: From now on, I will refer to this library as SBLogger.
This library was developed using C++17 and thus you will have the best experience using a C++17 (or later) compiler. For compilers pre C++17 (C++11 or C++14) or post C++17 (as of this writing, C++20), please refer to Setting Up.
All you need to do if you wish to use SBLogger (in a C++ project) is to clone/fork the repo or download the SmallBetterLogger.hpp
file to your project and add it as a header file in your code:
...
#include "SmallBetterLogger.hpp"
...
After including the library and defining the required macros/settings, as shown above, to start logging messages all you need to do is create an instance of a logger. All loggers are found in the sblogger
namespace.
Here are some quick examples of how to log messages:
Note: More information can be found in the Logging Messages page and more examples in the Usage Examples page.
...
#include "SmallBetterLogger.hpp"
...
sblogger::StreamLogger logger;
...
logger.WriteLine("Hello World!");
...
Output:
Hello World!
...
#include "SmallBetterLogger.hpp"
...
sblogger::FileLogger logger("my.log");
...
logger.WriteLine("Hello");
logger.Write("{0}!", "World");
...
Output:
#In "my.log"
Hello
World!