-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger_debugger.h
More file actions
29 lines (25 loc) · 793 Bytes
/
logger_debugger.h
File metadata and controls
29 lines (25 loc) · 793 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
/*
* logger_debugger.h
*
* Created on: Jun 5, 2020
* Author: sajeeb
*/
#ifndef LOGGER_DEBUGGER_H_
#define LOGGER_DEBUGGER_H_
#ifdef __LOGGER_DEBUGGER__
#define __LOGGER_DEBUGGER__(fmt, ...) {\
std::stringstream ss;\
ss << std::this_thread::get_id();\
const unsigned long long int id = std::stoull(ss.str());\
const auto duration = std::chrono::system_clock::now().time_since_epoch();\
const unsigned long int millis =\
std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();\
const char* ___file___ = __FILE__;\
const int ___line___ = __LINE__;\
printf("[%llu][%lu]: %s:%d:: " fmt "\n", id, millis, ___file___, ___line___, ##__VA_ARGS__);\
fflush((FILE*)stdout);\
}
#else
#define __LOGGER_DEBUGGER__(fmt, ...)
#endif
#endif /* LOGGER_DEBUGGER_H_ */