-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlog_example.cpp
More file actions
42 lines (34 loc) · 1.1 KB
/
Copy pathstreamlog_example.cpp
File metadata and controls
42 lines (34 loc) · 1.1 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
#include <streamlog.hpp>
#ifdef ENABLE_VECTOR_LOGGING
#include <vector>
#endif
#ifdef ENABLE_MAP_LOGGING
#include <map>
#endif
int main()
{
// Basic data types
log(TRACE) << "Logging an integer: " << 123;
log(DEBUG) << "Logging a double: " << 3.14;
log(INFO) << "Logging a character: " << 'C';
log(WARN) << "Logging a string: " << "Hello, World!";
log(ERROR) << "Logging a boolean: " << true;
//Complex data types
#ifdef ENABLE_VECTOR_LOGGING
std::vector<int> vec = {1, 2, 3, 4, 5};
log(TRACE) << "Logging a vector: " << vec;
#endif
#ifdef ENABLE_MAP_LOGGING
std::map<std::string, int> map = {{"apple", 5}, {"banana", 3}};
log(DEBUG) << "Logging a map: " << map;
#endif
// Real-world scenarios
int itemsProcessed = 10;
int totalItems = 20;
log(WARN) << "Processed " << itemsProcessed << " out of " << totalItems << " items.";
std::string username = "user123";
log(ERROR) << "Failed to find user with username: " << username;
std::string serviceName = "Database";
log(FATAL) << "The " << serviceName << " service failed to start.";
return 0;
}