| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // file_logger.cpp
- // logger
- //
- // Created by Sam Jaffe on 10/2/15.
- //
- //
- #include "logger.hpp"
- #include "default_logger_binding.hpp"
- #include <fstream>
- namespace logging {
- class file_logger : public logger_impl {
- public:
- static std::unique_ptr<logger_impl> create(logging::properties const&);
-
- file_logger(const std::string& fname);
-
- void write(log_level level, std::string const& msg) override;
- void flush() override;
- private:
- std::ofstream out_;
- };
-
- std::unique_ptr<logger_impl> file_logger::create(properties const&) {
- return std::unique_ptr<logger_impl>(); // TODO
- }
-
- file_logger::file_logger(const std::string& fname)
- : out_(fname) {}
-
- void file_logger::write(log_level level, std::string const& msg) {
- out_ << msg;
- }
-
- void file_logger::flush() {
- out_.flush();
- }
-
- namespace {
- bool _ = default_logger_impl::register_impl("File", file_logger::create);
- }
- }
|