Browse Source

Use coarse timestamp format

Since format in milliseconds doesn't add additional value and is
slower than just seconds.
adaptive-webui-19844
Chocobo1 2 years ago
parent
commit
af78344e5d
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 2
      src/app/filelogger.cpp
  2. 4
      src/base/bittorrent/statistics.cpp
  3. 4
      src/base/logger.cpp
  4. 4
      src/gui/log/logmodel.cpp

2
src/app/filelogger.cpp

@ -146,7 +146,7 @@ void FileLogger::addLogMessage(const Log::Msg &msg) @@ -146,7 +146,7 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
stream << QStringView(u"(N) ");
}
stream << QDateTime::fromMSecsSinceEpoch(msg.timestamp).toString(Qt::ISODate) << QStringView(u" - ") << msg.message << QChar(u'\n');
stream << QDateTime::fromSecsSinceEpoch(msg.timestamp).toString(Qt::ISODate) << QStringView(u" - ") << msg.message << QChar(u'\n');
if (m_backup && (m_logFile.size() >= m_maxSize))
{

4
src/base/bittorrent/statistics.cpp

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
#include "base/bittorrent/sessionstatus.h"
#include "base/profile.h"
const qint64 SAVE_INTERVAL = 15 * 60 * 1000;
const qint64 SAVE_INTERVAL = 15 * 60; // seconds
using namespace BitTorrent;
@ -84,7 +84,7 @@ void Statistics::gather() @@ -84,7 +84,7 @@ void Statistics::gather()
void Statistics::save() const
{
const qint64 now = QDateTime::currentMSecsSinceEpoch();
const qint64 now = QDateTime::currentSecsSinceEpoch();
if (!m_dirty || ((now - m_lastWrite) < SAVE_INTERVAL))
return;

4
src/base/logger.cpp

@ -73,7 +73,7 @@ void Logger::freeInstance() @@ -73,7 +73,7 @@ void Logger::freeInstance()
void Logger::addMessage(const QString &message, const Log::MsgType &type)
{
QWriteLocker locker(&m_lock);
const Log::Msg msg = {m_msgCounter++, type, QDateTime::currentMSecsSinceEpoch(), message};
const Log::Msg msg = {m_msgCounter++, type, QDateTime::currentSecsSinceEpoch(), message};
m_messages.push_back(msg);
locker.unlock();
@ -83,7 +83,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type) @@ -83,7 +83,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
void Logger::addPeer(const QString &ip, const bool blocked, const QString &reason)
{
QWriteLocker locker(&m_lock);
const Log::Peer msg = {m_peerCounter++, blocked, QDateTime::currentMSecsSinceEpoch(), ip, reason};
const Log::Peer msg = {m_peerCounter++, blocked, QDateTime::currentSecsSinceEpoch(), ip, reason};
m_peers.push_back(msg);
locker.unlock();

4
src/gui/log/logmodel.cpp

@ -155,7 +155,7 @@ LogMessageModel::LogMessageModel(QObject *parent) @@ -155,7 +155,7 @@ LogMessageModel::LogMessageModel(QObject *parent)
void LogMessageModel::handleNewMessage(const Log::Msg &message)
{
const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(message.timestamp), QLocale::ShortFormat);
const QString time = QLocale::system().toString(QDateTime::fromSecsSinceEpoch(message.timestamp), QLocale::ShortFormat);
const QString messageText = message.message;
const QColor foreground = m_foregroundForMessageTypes[message.type];
@ -173,7 +173,7 @@ LogPeerModel::LogPeerModel(QObject *parent) @@ -173,7 +173,7 @@ LogPeerModel::LogPeerModel(QObject *parent)
void LogPeerModel::handleNewMessage(const Log::Peer &peer)
{
const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(peer.timestamp), QLocale::ShortFormat);
const QString time = QLocale::system().toString(QDateTime::fromSecsSinceEpoch(peer.timestamp), QLocale::ShortFormat);
const QString message = peer.blocked
? tr("%1 was blocked. Reason: %2.", "0.0.0.0 was blocked. Reason: reason for blocking.").arg(peer.ip, peer.reason)
: tr("%1 was banned", "0.0.0.0 was banned").arg(peer.ip);

Loading…
Cancel
Save