wip: file log
This commit is contained in:
parent
4756a00156
commit
46224d331c
4 changed files with 58 additions and 4 deletions
35
src/debug.h
35
src/debug.h
|
|
@ -2,6 +2,26 @@
|
|||
|
||||
#if defined (QT_DEBUG) || defined (DEBUG) || defined (_DEBUG)
|
||||
|
||||
#ifdef INIT_FILELOG
|
||||
FILE* fileLog;
|
||||
errno_t lfResult;
|
||||
bool writable = false;
|
||||
|
||||
bool initializeFileLogging() {
|
||||
lfResult = fopen_s(&fileLog, "log.txt", "w");
|
||||
if (!lfResult) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
#else
|
||||
extern errno_t lfResult;
|
||||
extern FILE* fileLog;
|
||||
extern bool writable;
|
||||
extern bool initializeFileLogging();
|
||||
#endif
|
||||
|
||||
#define initialize_file_log() initializeFileLogging()
|
||||
|
||||
template<size_t Y, typename T>
|
||||
std::bitset<Y> varToBitset(T info) {
|
||||
std::bitset<Y> content(info);
|
||||
|
|
@ -15,6 +35,7 @@ std::bitset<Y> varToBitset(T info) {
|
|||
#define log_wdebugcpp(str) do { \
|
||||
std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#include <Windows.h>
|
||||
|
|
@ -29,19 +50,31 @@ std::bitset<Y> varToBitset(T info) {
|
|||
#define log_wdebugcpp(str) do { \
|
||||
OutputDebugStringW(std::wstring(L"[DEBUG] (" + std::wstring(WFILE) + L":" + std::to_wstring(__LINE__) + L"): " + std::wstring(str) +L"\n").c_str()); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define log_to_file(fmt, cnt) do { \
|
||||
if(writable) fprintf_s(fileLog, fmt, cnt); \
|
||||
} while (0)
|
||||
|
||||
#define print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||
|
||||
#define close_file_log_buffer() do { \
|
||||
fclose(fileLog); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define log_debugcpp(str)
|
||||
#define log_wdebugcpp(str)
|
||||
#define print_as_binary(len, type, info)
|
||||
#define log_to_file(fmt, cnt)
|
||||
#define initialize_file_log() false
|
||||
#define close_file_log_buffer()
|
||||
#endif
|
||||
|
||||
/* Here as a quick reference, in case smthn similar is needed again */
|
||||
/* typedef void (EndpointWidget::*epwMuteFunc)(bool muted); */
|
||||
/* typedef void (EndpointWidget::*epwMainVolumeFunc)(float newValue); */
|
||||
/* Typedef void (EndpointWidget::*epwMainVolumeFunc)(float newValue); */
|
||||
/* typedef void (EndpointWidget::*epwChannelVolumeFunc)(uint32_t channel, float newValue); */
|
||||
/* typedef void (EndpointWidget::*epwToggleFrontFunc)(bool active); */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue