Simple-Log  alpha-v0.7
FileLogging/main.cpp
1 // Copyright Dominic Koepke 2021 - 2021.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // https://www.boost.org/LICENSE_1_0.txt)
5 
6 /* With inclusion of this header, there will be automatically gCore, gConsoleSink and gLog constructed, which you might use.*/
8 
9 // just pull everything into the current namespace
10 using namespace sl::log::ready_to_go;
11 
12 // this creates a new FileSink object, which will store all incoming messages in logfile.log
13 auto& gFileSink = gCore.makeSink<FileSink_t>("logfile.log");
14 
15 int main()
16 {
17  // Let our FileSink only handle important messages, e.g. warning and above
18  gFileSink.setFilter(makeSeverityFilterFor<Record_t>(GreaterEquals{ SevLvl::warning }));
19 
20  // this message will only appear on the console
21  gLog() << "Hello, World!";
22 
23  // while this message will also be saved in our logfile.log. Go ahead and see it yourself ;)
24  gLog() << SetSev(SevLvl::warning) << "I'm an exemplary warning!";
25 }
void setFilter(TFilter &&filter)
Sets the active filter.
Definition: BasicSink.hpp:207
requires std::constructible_from< TSink, TArgs... > TSink & makeSink(TArgs &&... args)
Creates Sink and registers it at this Core instance.
Definition: Core.hpp:130
Class for logging into files.
Definition: FileSink.hpp:81
Compares greater-equality-ordering with constant at invocation.
Definition: Predicates.hpp:135
Manipulates the channel of the current RecordBuilder object.
Definition: RecordBuilder.hpp:31
Definition: ReadyToGo.hpp:14
auto gLog
Definition: ReadyToGo.hpp:20
Core_t gCore
Definition: ReadyToGo.hpp:18