#pragma once

#include <boost/noncopyable.hpp>
#include <QDateTime>
#include <QFile>
#include <QString>

#include <memory>

namespace chatterino {

class Logging;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;

class LoggingChannel : boost::noncopyable
{
    explicit LoggingChannel(const QString &_channelName,
                            const QString &platform);

public:
    ~LoggingChannel();
    void addMessage(MessagePtr message);

private:
    void openLogFile();

    QString generateOpeningString(
        const QDateTime &now = QDateTime::currentDateTime()) const;
    QString generateClosingString(
        const QDateTime &now = QDateTime::currentDateTime()) const;

    void appendLine(const QString &line);

    QString generateDateString(const QDateTime &now);

    const QString channelName;
    const QString platform;
    QString baseDirectory;
    QString subDirectory;

    QFile fileHandle;

    QString dateString;

    friend class Logging;
};

}  // namespace chatterino
