MCPcopy Create free account
hub / github.com/LibrePCB/LibrePCB / setDebugLevelLogFile

Method setDebugLevelLogFile

libs/librepcb/core/debug.cpp:76–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void Debug::setDebugLevelLogFile(DebugLevel_t level) {
77 if (level == mDebugLevelLogFile) return;
78
79 if ((mDebugLevelLogFile == DebugLevel_t::Nothing) &&
80 (level != DebugLevel_t::Nothing)) {
81 // enable logging to file
82 QDir().mkpath(mLogFilepath.getParentDir().toStr());
83 mLogFile = new QFile(mLogFilepath.toStr());
84 bool success = mLogFile->open(QFile::WriteOnly);
85 if (success) {
86 mDebugLevelLogFile = level; // activate logging to file immediately!
87 qDebug() << "Enabled logging to file:" << mLogFilepath.toNative();
88 } else {
89 qWarning().nospace() << "Failed to enable logging to file "
90 << mLogFilepath.toNative() << ": "
91 << mLogFile->errorString();
92 delete mLogFile;
93 mLogFile = nullptr;
94 }
95 } else if ((mDebugLevelLogFile != DebugLevel_t::Nothing) &&
96 (level == DebugLevel_t::Nothing) && (mLogFile)) {
97 // disable logging to file
98 mLogFile->close();
99 delete mLogFile;
100 mLogFile = nullptr;
101 }
102
103 mDebugLevelLogFile = level;
104}
105
106Debug::DebugLevel_t Debug::getDebugLevelStderr() const {
107 return mDebugLevelStderr;

Callers 1

mainFunction · 0.80

Calls 5

getParentDirMethod · 0.80
toNativeMethod · 0.80
closeMethod · 0.80
toStrMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected