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)
|
#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>
|
template<size_t Y, typename T>
|
||||||
std::bitset<Y> varToBitset(T info) {
|
std::bitset<Y> varToBitset(T info) {
|
||||||
std::bitset<Y> content(info);
|
std::bitset<Y> content(info);
|
||||||
|
|
@ -15,6 +35,7 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
#define log_wdebugcpp(str) do { \
|
#define log_wdebugcpp(str) do { \
|
||||||
std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
@ -29,19 +50,31 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
#define log_wdebugcpp(str) do { \
|
#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()); \
|
OutputDebugStringW(std::wstring(L"[DEBUG] (" + std::wstring(WFILE) + L":" + std::to_wstring(__LINE__) + L"): " + std::wstring(str) +L"\n").c_str()); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#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 print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||||
|
|
||||||
|
#define close_file_log_buffer() do { \
|
||||||
|
fclose(fileLog); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define log_debugcpp(str)
|
#define log_debugcpp(str)
|
||||||
#define log_wdebugcpp(str)
|
#define log_wdebugcpp(str)
|
||||||
#define print_as_binary(len, type, info)
|
#define print_as_binary(len, type, info)
|
||||||
|
#define log_to_file(fmt, cnt)
|
||||||
|
#define initialize_file_log() false
|
||||||
|
#define close_file_log_buffer()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Here as a quick reference, in case smthn similar is needed again */
|
/* Here as a quick reference, in case smthn similar is needed again */
|
||||||
/* typedef void (EndpointWidget::*epwMuteFunc)(bool muted); */
|
/* 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::*epwChannelVolumeFunc)(uint32_t channel, float newValue); */
|
||||||
/* typedef void (EndpointWidget::*epwToggleFrontFunc)(bool active); */
|
/* typedef void (EndpointWidget::*epwToggleFrontFunc)(bool active); */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,9 @@ void MainWindow::compose() {
|
||||||
log_debugcpp("epw loop");
|
log_debugcpp("epw loop");
|
||||||
log_debugcpp("epw roles: " + std::to_string(epw->getEndpointHandler()->getRoles()));
|
log_debugcpp("epw roles: " + std::to_string(epw->getEndpointHandler()->getRoles()));
|
||||||
//std::bitset<sizeof(uint8_t)> content =
|
//std::bitset<sizeof(uint8_t)> content =
|
||||||
print_as_binary(8, uint8_t, (epw->getEndpointHandler()->getRoles()));
|
//print_as_binary(8, uint8_t, (epw->getEndpointHandler()->getRoles()));
|
||||||
//log_debugcpp(content);
|
//log_debugcpp(content);
|
||||||
varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
|
//varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -585,6 +585,7 @@ void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||||
/* og 1080p 120% testing values */
|
/* og 1080p 120% testing values */
|
||||||
this->mainLabel->setMaximumWidth((int)width * 0.50 /* 1080p 120%*/);
|
this->mainLabel->setMaximumWidth((int)width * 0.50 /* 1080p 120%*/);
|
||||||
this->mainLabel->setMinimumWidth((int)width * 0.50 /* 1080p 120%*/);
|
this->mainLabel->setMinimumWidth((int)width * 0.50 /* 1080p 120%*/);
|
||||||
|
|
||||||
if (cw) {
|
if (cw) {
|
||||||
this->cw->setMinimumSize(QSize(1, height * 0.06));
|
this->cw->setMinimumSize(QSize(1, height * 0.06));
|
||||||
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06));
|
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06));
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
//#include "contclasses.h"
|
//#include "contclasses.h"
|
||||||
|
#define INIT_FILELOG
|
||||||
#include "qtclasses.h"
|
#include "qtclasses.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
|
@ -31,10 +32,27 @@ QLocalServer* startSingleInstanceServer(QString appName) {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void closeDebugFileLog() {
|
||||||
|
close_file_log_buffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set_terminate
|
||||||
|
* void closeDebugFileLog2() {
|
||||||
|
* close_file_log_buffer();
|
||||||
|
* abort();
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
int main (int argc, char* argv[]) {
|
int main (int argc, char* argv[]) {
|
||||||
//QApplication::setStyle("windowsvista");
|
//QApplication::setStyle("windowsvista");
|
||||||
//Check if running
|
//Check if running
|
||||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||||
|
writable = initialize_file_log();
|
||||||
|
log_to_file("%d hola", 3);
|
||||||
|
//int bro = fprintf_s(fileLog, "hola\n");
|
||||||
|
//bro = fprintf(fileLog, "hola");
|
||||||
|
atexit(closeDebugFileLog);
|
||||||
|
//std::set_terminate(closeDebugFileLog2);
|
||||||
if (!isSingleInstanceRunning("Mixer"))
|
if (!isSingleInstanceRunning("Mixer"))
|
||||||
startSingleInstanceServer("Mixer");
|
startSingleInstanceServer("Mixer");
|
||||||
else exit(0);
|
else exit(0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue