KIMAP

sessionlogger.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 SPDX-FileContributor: Kevin Ottens <kevin@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "sessionlogger_p.h"
9
10#include "kimap_debug.h"
11#include <QCoreApplication>
12
13using namespace KIMAP;
14
15SessionLogger::SessionLogger()
16{
17 static qint64 nextId = 0;
18 m_id = ++nextId;
19
20 m_file.setFileName(QLatin1StringView(qgetenv("KIMAP_LOGFILE")) + QLatin1Char('.') + QString::number(QCoreApplication::applicationPid()) + QLatin1Char('.')
21 + QString::number(m_id));
22 if (!m_file.open(QFile::WriteOnly)) {
23 qCWarning(KIMAP_LOG) << "Could not open log file for writing:" << m_file.fileName();
24 }
25}
26
27SessionLogger::~SessionLogger()
28{
29 m_file.close();
30}
31
32void SessionLogger::dataSent(const QByteArray &data)
33{
34 m_file.write("C: " + data.trimmed() + '\n');
35 m_file.flush();
36}
37
38void SessionLogger::dataReceived(const QByteArray &data)
39{
40 m_file.write("S: " + data.trimmed() + '\n');
41 m_file.flush();
42}
43
44void SessionLogger::disconnectionOccured()
45{
46 m_file.write("X\n");
47}
QByteArray trimmed() const const
qint64 applicationPid()
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:51:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.