forked from quickshell/quickshell
core/log: add read-log --no-time
This commit is contained in:
parent
c2b4610acb
commit
53b8f1ee0b
3 changed files with 7 additions and 4 deletions
|
@ -641,7 +641,7 @@ bool EncodedLogReader::registerCategory() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool readEncodedLogs(QIODevice* device, const QString& rulespec) {
|
||||
bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec) {
|
||||
using namespace qt_logging_registry;
|
||||
|
||||
QList<QLoggingRule> rules;
|
||||
|
@ -700,7 +700,7 @@ bool readEncodedLogs(QIODevice* device, const QString& rulespec) {
|
|||
}
|
||||
|
||||
if (filter.shouldDisplay(message.type)) {
|
||||
LogMessage::formatMessage(stream, message, color, true);
|
||||
LogMessage::formatMessage(stream, message, color, timestamps);
|
||||
stream << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ private:
|
|||
LoggingThreadProxy threadProxy;
|
||||
};
|
||||
|
||||
bool readEncodedLogs(QIODevice* device, const QString& rulespec);
|
||||
bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec);
|
||||
|
||||
} // namespace qs::log
|
||||
|
||||
|
|
|
@ -142,6 +142,8 @@ int qs_main(int argc, char** argv) {
|
|||
/// ---
|
||||
QStringOption logPath;
|
||||
QStringOption logFilter;
|
||||
auto logNoTime = false;
|
||||
|
||||
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();
|
||||
|
||||
|
@ -151,6 +153,7 @@ int qs_main(int argc, char** argv) {
|
|||
"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)");
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
@ -169,7 +172,7 @@ int qs_main(int argc, char** argv) {
|
|||
qInfo() << "Reading log" << *logPath;
|
||||
}
|
||||
|
||||
return qs::log::readEncodedLogs(&file, *logFilter) ? 0 : -1;
|
||||
return qs::log::readEncodedLogs(&file, !logNoTime, *logFilter) ? 0 : -1;
|
||||
} else {
|
||||
|
||||
// NOLINTBEGIN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue