1 /* -*- mode: c++; c-basic-offset:4 -*- 2 utils/log.h 3 4 This file is part of Kleopatra, the KDE keymanager 5 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #pragma once 11 12 #include <utils/pimpl_ptr.h> 13 14 #include <memory> 15 16 #include <cstdio> 17 18 class QIODevice; 19 class QString; 20 21 namespace Kleo 22 { 23 24 class Log 25 { 26 public: 27 28 enum OpenMode { 29 Read = 0x1, 30 Write = 0x2 31 }; 32 33 static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, 34 const QString &msg); 35 36 static std::shared_ptr<const Log> instance(); 37 static std::shared_ptr<Log> mutableInstance(); 38 39 ~Log(); 40 41 bool ioLoggingEnabled() const; 42 void setIOLoggingEnabled(bool enabled); 43 44 QString outputDirectory() const; 45 void setOutputDirectory(const QString &path); 46 47 std::shared_ptr<QIODevice> createIOLogger(const std::shared_ptr<QIODevice> &wrapped, const QString &prefix, OpenMode mode) const; 48 49 FILE *logFile() const; 50 51 private: 52 Log(); 53 54 private: 55 class Private; 56 kdtools::pimpl_ptr<Private> d; 57 58 Q_DISABLE_COPY(Log) 59 }; 60 61 } 62 63