debug_log.cpp 931 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "base/debug_log.h"
  8. #include "base/integration.h"
  9. namespace base {
  10. void LogWriteMain(const QString &message) {
  11. if (Integration::Exists()) {
  12. Integration::Instance().logMessage(message);
  13. }
  14. }
  15. void LogWriteDebug(const QString &message, const char *file, int line) {
  16. Expects(!LogSkipDebug());
  17. Integration::Instance().logMessageDebug(QString("%1 (%2 : %3)").arg(
  18. message,
  19. QString::fromUtf8(file),
  20. QString::number(__LINE__)));
  21. }
  22. bool LogSkipDebug() {
  23. return !Integration::Exists() || Integration::Instance().logSkipDebug();
  24. }
  25. QString LogProfilePrefix() {
  26. const auto now = crl::profile();
  27. return '[' + QString::number(now / 1000., 'f', 3) + "] ";
  28. }
  29. } // namespace base