-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathe-BasicShowcase.cpp
More file actions
33 lines (25 loc) · 905 Bytes
/
e-BasicShowcase.cpp
File metadata and controls
33 lines (25 loc) · 905 Bytes
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
// Copyright (c) Borislav Stanimirov
// SPDX-License-Identifier: MIT
//
#include <jalog/Log.hpp>
#include <jalog/LogPrintf.hpp>
#include <string>
#include <string_view>
struct Person {
std::string name;
int age;
};
std::ostream& operator<<(std::ostream& o, const Person& p) {
return o << p.name << '(' << p.age << ')';
}
int main() {
JALOG(Debug, "Log integers: ", 34, ", or in a custom base: ", jalog::base<16>(255));
JALOG(Info, "Log floating point numbers with no precision loss: ", 12.4356631);
std::string str = "my string";
std::string_view sv = std::string_view(str).substr(0, 6);
JALOG(Warning, "Log strings: '", str, "' and string views '", sv, "'");
Person alice = {"Alice", 34};
JALOG(Error, "Log types with custom ostream output: ", alice);
JALOG_PRINTF(Critical, "Log printf style: %d, %.3f, %s", 43, 3.14159, str.c_str());
return 0;
}