File indexing completed on 2024-05-12 05:17:17
0001 /* 0002 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0003 SPDX-FileContributor: Kevin Ottens <kevin@kdab.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "sessionlogger_p.h" 0009 0010 #include "kimap_debug.h" 0011 #include <QCoreApplication> 0012 0013 using namespace KIMAP; 0014 0015 SessionLogger::SessionLogger() 0016 { 0017 static qint64 nextId = 0; 0018 m_id = ++nextId; 0019 0020 m_file.setFileName(QLatin1StringView(qgetenv("KIMAP_LOGFILE")) + QLatin1Char('.') + QString::number(QCoreApplication::applicationPid()) + QLatin1Char('.') 0021 + QString::number(m_id)); 0022 if (!m_file.open(QFile::WriteOnly)) { 0023 qCWarning(KIMAP_LOG) << "Could not open log file for writing:" << m_file.fileName(); 0024 } 0025 } 0026 0027 SessionLogger::~SessionLogger() 0028 { 0029 m_file.close(); 0030 } 0031 0032 void SessionLogger::dataSent(const QByteArray &data) 0033 { 0034 m_file.write("C: " + data.trimmed() + '\n'); 0035 m_file.flush(); 0036 } 0037 0038 void SessionLogger::dataReceived(const QByteArray &data) 0039 { 0040 m_file.write("S: " + data.trimmed() + '\n'); 0041 m_file.flush(); 0042 } 0043 0044 void SessionLogger::disconnectionOccured() 0045 { 0046 m_file.write("X\n"); 0047 }