Files
hack/bin/examples/logger/main.cpp
2026-02-22 13:13:10 +03:00

79 lines
2.0 KiB
C++

#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include "hack/logger/logger.hpp"
#include "hack/patterns/ring_buffer.hpp"
auto main(int argc, char *argv[]) -> int
{
std::string str = "hi";
hack::log()(str);
int i = 1;
double d = 2.0;
float f = 3.f;
std::vector<std::string> vs = { "a", "b", "c" };
std::list<int> l = { 1, 2, 3 };
std::deque<float> df = { 1.1f, 2.1f, 3.1f };
std::forward_list<int> fl = { 1, 2, 3 };
std::map<int, int> mi = { { 1, 1 }, { 2, 2 }, { 3, 3 } };
std::multimap<int, int> mmi = { { 1, 1 }, { 1, 1 }, { 2, 2 }, { 3, 3 } };
std::unordered_map<int, int> umi = { { 1, 1 }, { 1, 1 }, { 2, 2 }, { 3, 3 } };
std::tuple<int, std::string, bool> tp = { 1, "asdf", false };
std::stack<int> sti;
sti.push(1);
sti.push(2);
sti.push(3);
std::set<int> si = { 1, 2, 3 };
std::unordered_set<int> usi = { 1, 1, 1 };
hack::patterns::ring_buffer<int> rb;
rb.create(10);
for (int i = 0; i < 10; ++i) rb.put(i);
hack::log().set_devider(", ");
hack::log()(1, i, 3.1f, f, 4.3, d, "asdf");
hack::log().set_devider(" = ");
hack::log().on_full_path();
hack::log()(1, i, 3.1f, f, 4.3, d, "asdf");
hack::log().reset();
hack::log()(1, i, 3.1f, f, 4.3, d, "asdf");
hack::log().set_devider(", ");
hack::log().on_func();
hack::log().on_file(false);
hack::log().on_row(false);
hack::log()(vs);
hack::log()(l);
hack::log()(df);
hack::log()(fl);
hack::log().reset();
hack::log()(mi);
hack::log()(mmi);
hack::log()(umi);
hack::log()("tuple:", tp);
hack::log()(true);
hack::log().bool_as_number();
hack::log()(true);
hack::log()(si);
hack::log()(usi);
hack::log().reset();
hack::log().set_devider(", ");
hack::log()(sti, 123, true);
hack::log().reset();
hack::log().on_full_path();
hack::log()("log", 123, sti, false, 1.8f, vs);
hack::warn()("warn");
hack::error()("error");
hack::log()(rb);
hack::log()(str.c_str());
std::filesystem::path p { "/test/file/path.txt" };
hack::log()(p);
return 0;
}