Akonadi

filetracer.cpp
1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2006 Tobias Koenig <[email protected]> *
3  * *
4  * SPDX-License-Identifier: LGPL-2.0-or-later *
5  ***************************************************************************/
6 #include "filetracer.h"
7 
8 #include <QTime>
9 
10 using namespace Akonadi::Server;
11 
12 FileTracer::FileTracer(const QString &fileName)
13  : m_file(fileName)
14 {
16 }
17 
18 FileTracer::~FileTracer() = default;
19 
20 void FileTracer::beginConnection(const QString &identifier, const QString &msg)
21 {
22  output(identifier, QStringLiteral("begin_connection: %1").arg(msg));
23 }
24 
25 void FileTracer::endConnection(const QString &identifier, const QString &msg)
26 {
27  output(identifier, QStringLiteral("end_connection: %1").arg(msg));
28 }
29 
30 void FileTracer::connectionInput(const QString &identifier, const QByteArray &msg)
31 {
32  output(identifier, QStringLiteral("input: %1").arg(QString::fromUtf8(msg)));
33 }
34 
35 void FileTracer::connectionOutput(const QString &identifier, const QByteArray &msg)
36 {
37  output(identifier, QStringLiteral("output: %1").arg(QString::fromUtf8(msg)));
38 }
39 
40 void FileTracer::signal(const QString &signalName, const QString &msg)
41 {
42  output(QStringLiteral("signal"), QStringLiteral("<%1> %2").arg(signalName, msg));
43 }
44 
45 void FileTracer::warning(const QString &componentName, const QString &msg)
46 {
47  output(QStringLiteral("warning"), QStringLiteral("<%1> %2").arg(componentName, msg));
48 }
49 
50 void FileTracer::error(const QString &componentName, const QString &msg)
51 {
52  output(QStringLiteral("error"), QStringLiteral("<%1> %2").arg(componentName, msg));
53 }
54 
55 void 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 }
QString fromUtf8(const char *str, int size)
QTime currentTime()
QByteArray toUtf8() const const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString left(int n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.