File indexing completed on 2025-12-17 10:29:01
0001
0002
0003
0004 #pragma once
0005
0006 #ifndef SPDLOG_HEADER_ONLY
0007 #include <spdlog/sinks/basic_file_sink.h>
0008 #endif
0009
0010 #include <spdlog/common.h>
0011 #include <spdlog/details/os.h>
0012
0013 namespace spdlog {
0014 namespace sinks {
0015
0016 template <typename Mutex>
0017 SPDLOG_INLINE basic_file_sink<Mutex>::basic_file_sink(const filename_t &filename,
0018 bool truncate,
0019 const file_event_handlers &event_handlers)
0020 : file_helper_{event_handlers} {
0021 file_helper_.open(filename, truncate);
0022 }
0023
0024 template <typename Mutex>
0025 SPDLOG_INLINE const filename_t &basic_file_sink<Mutex>::filename() const {
0026 return file_helper_.filename();
0027 }
0028
0029 template <typename Mutex>
0030 SPDLOG_INLINE void basic_file_sink<Mutex>::sink_it_(const details::log_msg &msg) {
0031 memory_buf_t formatted;
0032 base_sink<Mutex>::formatter_->format(msg, formatted);
0033 file_helper_.write(formatted);
0034 }
0035
0036 template <typename Mutex>
0037 SPDLOG_INLINE void basic_file_sink<Mutex>::flush_() {
0038 file_helper_.flush();
0039 }
0040
0041 }
0042 }