core/log: add read-log --no-time

This commit is contained in:
outfoxxed 2024-08-09 23:58:30 -07:00
parent c2b4610acb
commit 53b8f1ee0b
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 7 additions and 4 deletions

View file

@ -641,7 +641,7 @@ bool EncodedLogReader::registerCategory() {
return true; return true;
} }
bool readEncodedLogs(QIODevice* device, const QString& rulespec) { bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec) {
using namespace qt_logging_registry; using namespace qt_logging_registry;
QList<QLoggingRule> rules; QList<QLoggingRule> rules;
@ -700,7 +700,7 @@ bool readEncodedLogs(QIODevice* device, const QString& rulespec) {
} }
if (filter.shouldDisplay(message.type)) { if (filter.shouldDisplay(message.type)) {
LogMessage::formatMessage(stream, message, color, true); LogMessage::formatMessage(stream, message, color, timestamps);
stream << '\n'; stream << '\n';
} }
} }

View file

@ -98,7 +98,7 @@ private:
LoggingThreadProxy threadProxy; LoggingThreadProxy threadProxy;
}; };
bool readEncodedLogs(QIODevice* device, const QString& rulespec); bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec);
} // namespace qs::log } // namespace qs::log

View file

@ -142,6 +142,8 @@ int qs_main(int argc, char** argv) {
/// --- /// ---
QStringOption logPath; QStringOption logPath;
QStringOption logFilter; QStringOption logFilter;
auto logNoTime = false;
auto* readLog = app.add_subcommand("read-log", "Read a quickshell log file."); auto* readLog = app.add_subcommand("read-log", "Read a quickshell log file.");
readLog->add_option("path", logPath, "Path to the log file to read")->required(); readLog->add_option("path", logPath, "Path to the log file to read")->required();
@ -151,6 +153,7 @@ int qs_main(int argc, char** argv) {
"Logging categories to display. (same syntax as QT_LOGGING_RULES)" "Logging categories to display. (same syntax as QT_LOGGING_RULES)"
); );
readLog->add_flag("--no-time", logNoTime, "Do not print timestamps of log messages.");
readLog->add_flag("--no-color", noColor, "Do not color the log output. (Env:NO_COLOR)"); readLog->add_flag("--no-color", noColor, "Do not color the log output. (Env:NO_COLOR)");
CLI11_PARSE(app, argc, argv); CLI11_PARSE(app, argc, argv);
@ -169,7 +172,7 @@ int qs_main(int argc, char** argv) {
qInfo() << "Reading log" << *logPath; qInfo() << "Reading log" << *logPath;
} }
return qs::log::readEncodedLogs(&file, *logFilter) ? 0 : -1; return qs::log::readEncodedLogs(&file, !logNoTime, *logFilter) ? 0 : -1;
} else { } else {
// NOLINTBEGIN // NOLINTBEGIN