Use LOG/DEBUG_LOG from lib_base.

This commit is contained in:
John Preston 2021-04-20 16:25:31 +04:00
parent 50a0e7da64
commit d07bee87cd
9 changed files with 19 additions and 56 deletions

View file

@ -211,8 +211,6 @@ PRIVATE
ui/round_rect.h ui/round_rect.h
ui/rp_widget.cpp ui/rp_widget.cpp
ui/rp_widget.h ui/rp_widget.h
ui/ui_log.cpp
ui/ui_log.h
ui/ui_utility.cpp ui/ui_utility.cpp
ui/ui_utility.h ui/ui_utility.h

View file

@ -10,10 +10,10 @@
#include "base/bytes.h" #include "base/bytes.h"
#include "base/openssl_help.h" #include "base/openssl_help.h"
#include "base/parse_helper.h" #include "base/parse_helper.h"
#include "base/debug_log.h"
#include "ui/style/style_core.h" #include "ui/style/style_core.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "ui/ui_log.h"
#include "styles/style_basic.h" #include "styles/style_basic.h"
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
@ -218,7 +218,7 @@ void SaveToFile(int id, const QImage &image, int size, int index) {
if (!f.open(QIODevice::WriteOnly)) { if (!f.open(QIODevice::WriteOnly)) {
if (!QDir::current().mkpath(internal::CacheFileFolder()) if (!QDir::current().mkpath(internal::CacheFileFolder())
|| !f.open(QIODevice::WriteOnly)) { || !f.open(QIODevice::WriteOnly)) {
UI_LOG(("App Error: Could not open emoji cache '%1' for size %2_%3" LOG(("App Error: Could not open emoji cache '%1' for size %2_%3"
).arg(f.fileName() ).arg(f.fileName()
).arg(size ).arg(size
).arg(index)); ).arg(index));
@ -244,7 +244,7 @@ void SaveToFile(int id, const QImage &image, int size, int index) {
|| !write(data) || !write(data)
|| !write(openssl::Sha256(bytes::make_span(header), data)) || !write(openssl::Sha256(bytes::make_span(header), data))
|| false) { || false) {
UI_LOG(("App Error: Could not write emoji cache '%1' for size %2" LOG(("App Error: Could not write emoji cache '%1' for size %2"
).arg(f.fileName() ).arg(f.fileName()
).arg(size)); ).arg(size));
} }

View file

@ -35,7 +35,6 @@ public:
virtual void registerLeaveSubscription(not_null<QWidget*> widget) = 0; virtual void registerLeaveSubscription(not_null<QWidget*> widget) = 0;
virtual void unregisterLeaveSubscription(not_null<QWidget*> widget) = 0; virtual void unregisterLeaveSubscription(not_null<QWidget*> widget) = 0;
virtual void writeLogEntry(const QString &entry) = 0;
[[nodiscard]] virtual QString emojiCacheFolder() = 0; [[nodiscard]] virtual QString emojiCacheFolder() = 0;
virtual void textActionsUpdated(); virtual void textActionsUpdated();

View file

@ -6,9 +6,9 @@
// //
#include "ui/platform/linux/ui_utility_linux.h" #include "ui/platform/linux/ui_utility_linux.h"
#include "ui/ui_log.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_gtk_integration.h" #include "base/platform/linux/base_linux_gtk_integration.h"
#include "base/debug_log.h"
#include "ui/platform/linux/ui_linux_wayland_integration.h" #include "ui/platform/linux/ui_linux_wayland_integration.h"
#include "base/const_string.h" #include "base/const_string.h"
#include "base/qt_adapters.h" #include "base/qt_adapters.h"
@ -422,10 +422,10 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
static auto WarnedAbout = base::flat_set<int>(); static auto WarnedAbout = base::flat_set<int>();
if (!WarnedAbout.contains(index)) { if (!WarnedAbout.contains(index)) {
WarnedAbout.emplace(index); WarnedAbout.emplace(index);
UI_LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y())); LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
} }
} else { } else {
UI_LOG(("WARNING: Could not get screen for position %1,%2").arg(globalPosition.x()).arg(globalPosition.y())); LOG(("WARNING: Could not get screen for position %1,%2").arg(globalPosition.x()).arg(globalPosition.y()));
} }
} }
} }

View file

@ -10,7 +10,7 @@
#include "ui/platform/win/ui_window_title_win.h" #include "ui/platform/win/ui_window_title_win.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/platform/win/base_windows_safe_library.h" #include "base/platform/win/base_windows_safe_library.h"
#include "base/integration.h" #include "base/debug_log.h"
#include "styles/palette.h" #include "styles/palette.h"
#include <QtCore/QAbstractNativeEventFilter> #include <QtCore/QAbstractNativeEventFilter>
@ -75,7 +75,7 @@ bool IsTaskbarAutoHidden(LPRECT rcMon = nullptr, PUINT pEdge = nullptr) {
*pEdge = pos.uEdge; *pEdge = pos.uEdge;
} }
} else { } else {
base::Integration::Instance().logMessage("Failed to get taskbar pos"); DEBUG_LOG(("Failed to get taskbar pos"));
if (pEdge) { if (pEdge) {
*pEdge = ABE_BOTTOM; *pEdge = ABE_BOTTOM;
} }

View file

@ -6,9 +6,9 @@
// //
#include "ui/style/style_core_font.h" #include "ui/style/style_core_font.h"
#include "ui/style/style_core_custom_font.h"
#include "ui/ui_log.h"
#include "base/algorithm.h" #include "base/algorithm.h"
#include "base/debug_log.h"
#include "ui/style/style_core_custom_font.h"
#include "ui/integration.h" #include "ui/integration.h"
#include <QtCore/QMap> #include <QtCore/QMap>
@ -49,13 +49,13 @@ bool ValidateFont(const QString &familyName, int flags = 0) {
checkFont.setUnderline(flags & style::internal::FontUnderline); checkFont.setUnderline(flags & style::internal::FontUnderline);
auto realFamily = QFontInfo(checkFont).family(); auto realFamily = QFontInfo(checkFont).family();
if (realFamily.trimmed().compare(familyName, Qt::CaseInsensitive)) { if (realFamily.trimmed().compare(familyName, Qt::CaseInsensitive)) {
UI_LOG(("Font Error: could not resolve '%1' font, got '%2'.").arg(familyName, realFamily)); LOG(("Font Error: could not resolve '%1' font, got '%2'.").arg(familyName, realFamily));
return false; return false;
} }
auto metrics = QFontMetrics(checkFont); auto metrics = QFontMetrics(checkFont);
if (!metrics.height()) { if (!metrics.height()) {
UI_LOG(("Font Error: got a zero height in '%1'.").arg(familyName)); LOG(("Font Error: got a zero height in '%1'.").arg(familyName));
return false; return false;
} }
@ -65,13 +65,13 @@ bool ValidateFont(const QString &familyName, int flags = 0) {
bool LoadCustomFont(const QString &filePath, const QString &familyName, int flags = 0) { bool LoadCustomFont(const QString &filePath, const QString &familyName, int flags = 0) {
auto regularId = QFontDatabase::addApplicationFont(filePath); auto regularId = QFontDatabase::addApplicationFont(filePath);
if (regularId < 0) { if (regularId < 0) {
UI_LOG(("Font Error: could not add '%1'.").arg(filePath)); LOG(("Font Error: could not add '%1'.").arg(filePath));
return false; return false;
} }
const auto found = [&] { const auto found = [&] {
for (auto &family : QFontDatabase::applicationFontFamilies(regularId)) { for (auto &family : QFontDatabase::applicationFontFamilies(regularId)) {
UI_LOG(("Font: from '%1' loaded '%2'").arg(filePath, family)); LOG(("Font: from '%1' loaded '%2'").arg(filePath, family));
if (!family.trimmed().compare(familyName, Qt::CaseInsensitive)) { if (!family.trimmed().compare(familyName, Qt::CaseInsensitive)) {
return true; return true;
} }
@ -79,7 +79,7 @@ bool LoadCustomFont(const QString &filePath, const QString &familyName, int flag
return false; return false;
}(); }();
if (!found) { if (!found) {
UI_LOG(("Font Error: could not locate '%1' font in '%2'.").arg(familyName, filePath)); LOG(("Font Error: could not locate '%1' font in '%2'.").arg(familyName, filePath));
return false; return false;
} }
@ -200,7 +200,7 @@ void StartFonts() {
if (!areGood[i]) { if (!areGood[i]) {
if (ValidateFont(fallback, flags)) { if (ValidateFont(fallback, flags)) {
Overrides[i] = fallback; Overrides[i] = fallback;
UI_LOG(("Fonts Info: Using '%1' instead of '%2'.").arg(fallback).arg(name)); LOG(("Fonts Info: Using '%1' instead of '%2'.").arg(fallback).arg(name));
} }
} }
// Disable default fallbacks to Segoe UI, see: // Disable default fallbacks to Segoe UI, see:

View file

@ -7,7 +7,7 @@
#include "ui/text/text_block.h" #include "ui/text/text_block.h"
#include "styles/style_basic.h" #include "styles/style_basic.h"
#include "base/integration.h" #include "base/debug_log.h"
#include <private/qfontengine_p.h> #include <private/qfontengine_p.h>
@ -161,8 +161,8 @@ void addNextCluster(
for (auto i = 0; i < pos; ++i) { for (auto i = 0; i < pos; ++i) {
str.append(QString::number(logClusters[i])); str.append(QString::number(logClusters[i]));
} }
base::Integration::Instance().logAssertionViolation(QString("text: %1 (from: %2, length: %3) part: %4").arg(DebugCurrentParsingString).arg(DebugCurrentParsingFrom).arg(DebugCurrentParsingLength).arg(DebugCurrentParsingPart)); LOG(("text: %1 (from: %2, length: %3) part: %4").arg(DebugCurrentParsingString).arg(DebugCurrentParsingFrom).arg(DebugCurrentParsingLength).arg(DebugCurrentParsingPart));
base::Integration::Instance().logAssertionViolation(QString("pos: %1, end: %2, glyphPosition: %3, glyphCount: %4, lineLength: %5, num_glyphs: %6, logClusters[0..pos]: %7").arg(pos).arg(end).arg(glyphPosition).arg(glyphCount).arg(line.length).arg(current.num_glyphs).arg(str.join(","))); LOG(("pos: %1, end: %2, glyphPosition: %3, glyphCount: %4, lineLength: %5, num_glyphs: %6, logClusters[0..pos]: %7").arg(pos).arg(end).arg(glyphPosition).arg(glyphCount).arg(line.length).arg(current.num_glyphs).arg(str.join(",")));
Unexpected("Values in addNextCluster()"); Unexpected("Values in addNextCluster()");
} }
Q_ASSERT((pos == end && glyphPosition == current.num_glyphs) Q_ASSERT((pos == end && glyphPosition == current.num_glyphs)

View file

@ -1,19 +0,0 @@
// 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 "ui/ui_log.h"
#include "ui/integration.h"
namespace Ui {
void WriteLogEntry(const QString &message) {
if (Integration::Exists()) {
Integration::Instance().writeLogEntry(message);
}
}
} // namespace Ui

View file

@ -1,15 +0,0 @@
// 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
namespace Ui {
void WriteLogEntry(const QString &message);
} // namespace Ui
#define UI_LOG(message) (::Ui::WriteLogEntry(QString message))