Akonadi

filetracer.cpp
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> *
3 * *
4 * SPDX-License-Identifier: LGPL-2.0-or-later *
5 ***************************************************************************/
6#include "filetracer.h"
7
8#include <QTime>
9
10using namespace Akonadi::Server;
11
12FileTracer::FileTracer(const QString &fileName)
13 : m_file(fileName)
14{
16}
17
18FileTracer::~FileTracer() = default;
19
20void FileTracer::beginConnection(const QString &identifier, const QString &msg)
21{
22 output(identifier, QStringLiteral("begin_connection: %1").arg(msg));
23}
24
25void FileTracer::endConnection(const QString &identifier, const QString &msg)
26{
27 output(identifier, QStringLiteral("end_connection: %1").arg(msg));
28}
29
30void FileTracer::connectionInput(const QString &identifier, const QByteArray &msg)
31{
32 output(identifier, QStringLiteral("input: %1").arg(QString::fromUtf8(msg)));
33}
34
35void FileTracer::connectionOutput(const QString &identifier, const QByteArray &msg)
36{
37 output(identifier, QStringLiteral("output: %1").arg(QString::fromUtf8(msg)));
38}
39
40void FileTracer::signal(const QString &signalName, const QString &msg)
41{
42 output(QStringLiteral("signal"), QStringLiteral("<%1> %2").arg(signalName, msg));
43}
44
45void FileTracer::warning(const QString &componentName, const QString &msg)
46{
47 output(QStringLiteral("warning"), QStringLiteral("<%1> %2").arg(componentName, msg));
48}
49
50void FileTracer::error(const QString &componentName, const QString &msg)
51{
52 output(QStringLiteral("error"), QStringLiteral("<%1> %2").arg(componentName, msg));
53}
54
55void FileTracer::output(const QString &id, const QString &msg)
56{
57 QString output =
58 QStringLiteral("%1: %2: %3\r\n").arg(QTime::currentTime().toString(QStringLiteral("HH:mm:ss.zzz")), id, msg.left(msg.indexOf(QLatin1Char('\n'))));
59 m_file.write(output.toUtf8());
60}
void warning(const QString &componentName, const QString &msg) override
This method is called whenever a component wants to output a warning.
void error(const QString &componentName, const QString &msg) override
This method is called whenever a component wants to output an error.
void beginConnection(const QString &identifier, const QString &msg) override
This method is called whenever a new data (imap) connection to the akonadi server is established.
void endConnection(const QString &identifier, const QString &msg) override
This method is called whenever a data (imap) connection to akonadi server is closed.
void signal(const QString &signalName, const QString &msg) override
This method is called whenever a dbus signal is emitted on the bus.
void connectionInput(const QString &identifier, const QByteArray &msg) override
This method is called whenever the akonadi server retrieves some data from the outside.
void connectionOutput(const QString &identifier, const QByteArray &msg) override
This method is called whenever the akonadi server sends some data out to a client.
qint64 write(const QByteArray &data)
QString fromUtf8(QByteArrayView str)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
QByteArray toUtf8() const const
QTime currentTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 11:57:49 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.