-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathappender_file.cpp
More file actions
97 lines (81 loc) · 2.45 KB
/
appender_file.cpp
File metadata and controls
97 lines (81 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Created by Ivan Shynkarenka on 08.09.2016
//
#include "benchmark/cppbenchmark.h"
#include "logging/config.h"
#include "logging/logger.h"
using namespace CppCommon;
using namespace CppLogging;
class BinaryConfigFixture : public virtual CppBenchmark::Fixture
{
protected:
void Initialize(CppBenchmark::Context& context) override
{
auto binary_sink = std::make_shared<Processor>(std::make_shared<BinaryLayout>());
binary_sink->appenders().push_back(std::make_shared<FileAppender>(_file));
Config::ConfigLogger("binary", binary_sink);
Config::Startup();
}
void Cleanup(CppBenchmark::Context& context) override
{
Config::Shutdown();
if (_file.IsFileExists())
File::Remove(_file);
}
private:
File _file{"test.bin.log"};
};
class HashConfigFixture : public virtual CppBenchmark::Fixture
{
protected:
void Initialize(CppBenchmark::Context& context) override
{
auto hash_sink = std::make_shared<Processor>(std::make_shared<HashLayout>());
hash_sink->appenders().push_back(std::make_shared<FileAppender>(_file));
Config::ConfigLogger("hash", hash_sink);
Config::Startup();
}
void Cleanup(CppBenchmark::Context& context) override
{
Config::Shutdown();
if (_file.IsFileExists())
File::Remove(_file);
}
private:
File _file{"test.hash.log"};
};
class TextConfigFixture : public virtual CppBenchmark::Fixture
{
protected:
void Initialize(CppBenchmark::Context& context) override
{
auto text_sink = std::make_shared<Processor>(std::make_shared<TextLayout>());
text_sink->appenders().push_back(std::make_shared<FileAppender>(_file));
Config::ConfigLogger("text", text_sink);
Config::Startup();
}
void Cleanup(CppBenchmark::Context& context) override
{
Config::Shutdown();
if (_file.IsFileExists())
File::Remove(_file);
}
private:
File _file{"test.log"};
};
BENCHMARK_FIXTURE(BinaryConfigFixture, "FileAppender-binary")
{
static Logger logger = Config::CreateLogger("binary");
logger.Info("Test message");
}
BENCHMARK_FIXTURE(HashConfigFixture, "FileAppender-hash")
{
static Logger logger = Config::CreateLogger("hash");
logger.Info("Test message");
}
BENCHMARK_FIXTURE(TextConfigFixture, "FileAppender-text")
{
static Logger logger = Config::CreateLogger("text");
logger.Info("Test message");
}
BENCHMARK_MAIN()