#ifndef TILE_BASE_LOGGING_BASIC_FILE_SINK_H
#define TILE_BASE_LOGGING_BASIC_FILE_SINK_H

#pragma once
#include "tile/base/internal/logging.h"

#include <mutex>
#include <set>

namespace tile {
class BasicFileSink : public LogSink {
public:
    using Ptr = std::shared_ptr<BasicFileSink>;
    static Ptr Create(const std::string &filepath);

    ~BasicFileSink() override;

    const char *name() const override { return "BasicFileSink"; }

    void Send(LogSeverity severity,
              const char *full_filename,
              const char *base_filename,
              int line,
              const LogMessageTime &logmsgtime,
              const char *message,
              size_t message_len) override;
    void Flush() override;

    std::string filepath() const;
    void set_filepath(const std::string &filepath);

protected:
    BasicFileSink();

private:
    std::string filepath_;
    std::ofstream ofs_;
};

}// namespace tile

#endif// TILE_BASE_LOGGING_BASIC_FILE_SINK_H
