-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_test.cpp
52 lines (36 loc) · 1.11 KB
/
log_test.cpp
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
/*
* File: log_test.cpp
* Author: Thiago Massari Guedes
*
* Created on 17 de Maio de 2015, 23:38
*/
#include "Log.h"
#include <string>
#include <sstream>
#include <utility>
#include <functional>
#include <iostream>
using namespace std;
using namespace std::chrono;
using namespace BTL::Log;
//---- must be in log.cpp -----------------------------------------------
using Logger = log_callback<std::stringstream>; //get something better than stringstream
template<typename StreamPolicy>
log_callback<StreamPolicy> *log_callback<StreamPolicy>::_inst = nullptr;
level_format BTL::Log::level_format::_inst;
//=======================================================================
int main() {
Logger::init(log_level::ALL, [](int level, const std::string &text) {
const char *l = level_format::get_level(level);
print_timed_now(l, text);
});
Logger::audit(1, 2, 3, 4, "asdasdas", 1);
Logger::trace("thiago","massari ","guedes",1,2,3,"asd");
auto fmt_val = [](int val) -> std::string {
char buf[64];
sprintf(buf, "0x%X ", val);
return buf;
};
Logger::error(1, 2, 3, _TP(4, fmt_val), 5);
return 0;
}