-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LOG/DEBUG_LOG/PROFILE_LOG using Integration.
- Loading branch information
1 parent
443b7b6
commit 053ab21
Showing
10 changed files
with
143 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This file is part of Desktop App Toolkit, | ||
// a set of libraries for developing nice desktop applications. | ||
// | ||
// For license and copyright information please follow this link: | ||
// https://github.com/desktop-app/legal/blob/master/LEGAL | ||
// | ||
#include "base/debug_log.h" | ||
|
||
#include "base/integration.h" | ||
|
||
namespace base { | ||
|
||
void LogWriteMain(const QString &message) { | ||
if (Integration::Exists()) { | ||
Integration::Instance().logMessage(message); | ||
} | ||
} | ||
|
||
void LogWriteDebug(const QString &message, const char *file, int line) { | ||
Expects(!LogSkipDebug()); | ||
|
||
Integration::Instance().logMessageDebug(QString("%1 (%2 : %3)").arg( | ||
message, | ||
QString::fromUtf8(file), | ||
QString::number(__LINE__))); | ||
} | ||
|
||
bool LogSkipDebug() { | ||
return !Integration::Exists() || Integration::Instance().logSkipDebug(); | ||
} | ||
|
||
QString LogProfilePrefix() { | ||
const auto now = crl::profile(); | ||
return '[' + QString::number(now / 1000., 'f', 3) + "] "; | ||
} | ||
|
||
} // namespace base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This file is part of Desktop App Toolkit, | ||
// a set of libraries for developing nice desktop applications. | ||
// | ||
// For license and copyright information please follow this link: | ||
// https://github.com/desktop-app/legal/blob/master/LEGAL | ||
// | ||
#pragma once | ||
|
||
#include "base/assertion.h" // SOURCE_FILE_BASENAME | ||
|
||
namespace base { | ||
|
||
void LogWriteMain(const QString &message); | ||
void LogWriteDebug(const QString &message, const char *file, int line); | ||
[[nodiscard]] bool LogSkipDebug(); | ||
|
||
[[nodiscard]] QString LogProfilePrefix(); | ||
|
||
} // namespace base | ||
|
||
#define LOG(message) (::base::LogWriteMain(QString message)) | ||
//usage LOG(("log: %1 %2").arg(1).arg(2)) | ||
|
||
#define PROFILE_LOG(message) {\ | ||
if (!::base::LogSkipDebug()) {\ | ||
::base::LogWriteMain(::base::LogProfilePrefix() + QString msg);\ | ||
}\ | ||
} | ||
//usage PROFILE_LOG(("step: %1 %2").arg(1).arg(2)) | ||
|
||
#define DEBUG_LOG(msg) {\ | ||
if (!::base::LogSkipDebug()) {\ | ||
::base::LogWriteDebug(QString msg, SOURCE_FILE_BASENAME, __LINE__);\ | ||
}\ | ||
} | ||
//usage DEBUG_LOG(("log: %1 %2").arg(1).arg(2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.