2828#include " logging_p.hpp"
2929#include " logging_qtprivate.cpp" // NOLINT
3030#include " paths.hpp"
31+ #include " ringbuf.hpp"
3132
3233Q_LOGGING_CATEGORY (logBare, " quickshell.bare" );
3334
@@ -65,6 +66,7 @@ void LogMessage::formatMessage(
6566 }
6667
6768 if (msg.category == " quickshell.bare" ) {
69+ if (!prefix.isEmpty ()) stream << ' ' ;
6870 stream << msg.body ;
6971 } else {
7072 if (color) {
@@ -243,9 +245,9 @@ void LogManager::init(
243245 thread->start ();
244246
245247 QMetaObject::invokeMethod (
246- &instance->threadProxy ,
247- &LoggingThreadProxy::initInThread,
248- Qt::BlockingQueuedConnection
248+ &instance->threadProxy ,
249+ &LoggingThreadProxy::initInThread,
250+ Qt::BlockingQueuedConnection
249251 );
250252
251253 qCDebug (logLogging) << " Logger initialized." ;
@@ -735,7 +737,7 @@ bool EncodedLogReader::registerCategory() {
735737 return true ;
736738}
737739
738- bool readEncodedLogs (QIODevice* device, bool timestamps, const QString& rulespec) {
740+ bool readEncodedLogs (QIODevice* device, bool timestamps, int tail, const QString& rulespec) {
739741 QList<QLoggingRule> rules;
740742
741743 {
@@ -767,6 +769,8 @@ bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec
767769
768770 auto filters = QHash<quint16, CategoryFilter>();
769771
772+ auto tailRing = RingBuffer<LogMessage>(tail);
773+
770774 LogMessage message;
771775 auto stream = QTextStream (stdout);
772776 while (reader.read (&message)) {
@@ -782,6 +786,18 @@ bool readEncodedLogs(QIODevice* device, bool timestamps, const QString& rulespec
782786 }
783787
784788 if (filter.shouldDisplay (message.type )) {
789+ if (tail == 0 ) {
790+ LogMessage::formatMessage (stream, message, color, timestamps);
791+ stream << ' \n ' ;
792+ } else {
793+ tailRing.emplace (message);
794+ }
795+ }
796+ }
797+
798+ if (tail != 0 ) {
799+ for (auto i = tailRing.size () - 1 ; i != -1 ; i--) {
800+ auto & message = tailRing.at (i);
785801 LogMessage::formatMessage (stream, message, color, timestamps);
786802 stream << ' \n ' ;
787803 }
0 commit comments