From f20945edc7b65dc2a21842fac2a4977c9edc5d48 Mon Sep 17 00:00:00 2001 From: droidicus Date: Sat, 19 Jul 2025 06:30:31 -0400 Subject: [PATCH] feat: add setting to customize chat log timestamp (#6338) --- CHANGELOG.md | 1 + src/singletons/Settings.hpp | 5 ++++- src/singletons/helper/LoggingChannel.cpp | 10 +++++++--- src/widgets/settingspages/GeneralPage.cpp | 2 +- src/widgets/settingspages/ModerationPage.cpp | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29c006ea..ae46497a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Minor: Added hotkey Action for opening account selector. (#6192) - Minor: Add a setting to change the emote and badge thumbnail size. (#6126) - Minor: Add an import and export button to image uploader settings. (#6284) +- Minor: Add a setting under Moderation -> Logs to customize the timestamp used for chat logs. (#6338) - Bugfix: Commands are no longer tab-completable in the middle of messages. (#6273) - Bugfix: Automatic streamer mode detection now works from Flatpak. (#6250) - Bugfix: Don't create native messaging manifest file if browser directory doesn't exist. (#6116) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 78eac3db..eddd4981 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -567,7 +567,10 @@ public: "/logging/separatelyStoreStreamLogs", false, }; - + QStringSetting logTimestampFormat = { + "/logging/logTimestampFormat", + "hh:mm:ss", + }; QStringSetting logPath = {"/logging/path", ""}; QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath", diff --git a/src/singletons/helper/LoggingChannel.cpp b/src/singletons/helper/LoggingChannel.cpp index c27cb4c3..eb012361 100644 --- a/src/singletons/helper/LoggingChannel.cpp +++ b/src/singletons/helper/LoggingChannel.cpp @@ -182,9 +182,13 @@ void LoggingChannel::addMessage(const MessagePtr &message, str.append("#" + message->channelName + " "); } - str.append('['); - str.append(now.toString("HH:mm:ss")); - str.append("] "); + QString logTimestampFormat = getSettings()->logTimestampFormat; + if (logTimestampFormat != "Disable") + { + str.append('['); + str.append(now.toString(logTimestampFormat)); + str.append("] "); + } QString messageText; if (message->loginName.isEmpty()) diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index c783d047..fb39d350 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -521,7 +521,7 @@ void GeneralPage::initLayout(GeneralPageView &layout) ->addTo(layout); layout.addDropdown( - "Timestamp format", + "Message timestamp format", {"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", "hh:mm:ss", "h:mm:ss a", "hh:mm:ss a", "h:mm:ss.zzz", "h:mm:ss.zzz a", "hh:mm:ss.zzz", "hh:mm:ss.zzz a"}, diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index e7722710..4f5482a2 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -150,6 +150,21 @@ ModerationPage::ModerationPage() }).result()); }); + auto logsTimestampFormatLayout = + logs.emplace().withoutMargin(); + auto logsTimestampFormatLabel = + logsTimestampFormatLayout.emplace(); + logsTimestampFormatLabel->setText( + QString("Log file timestamp format: ")); + + QComboBox *logTimestampFormat = this->createComboBox( + {"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", + "hh:mm:ss", "h:mm:ss a", "hh:mm:ss a", "h:mm:ss.zzz", + "h:mm:ss.zzz a", "hh:mm:ss.zzz", "hh:mm:ss.zzz a"}, + getSettings()->logTimestampFormat); + logTimestampFormat->setToolTip("a = am/pm, zzz = milliseconds"); + logsTimestampFormatLayout.append(logTimestampFormat); + QCheckBox *onlyLogListedChannels = this->createCheckBox("Only log channels listed below", getSettings()->onlyLogListedChannels);