wip static-lib
This commit is contained in:
		
							
								
								
									
										39
									
								
								include/spdlog/sinks/basic_file_sink-inl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								include/spdlog/sinks/basic_file_sink-inl.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
 | 
			
		||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "spdlog/common.h"
 | 
			
		||||
#include "spdlog/details/os.h"
 | 
			
		||||
 | 
			
		||||
namespace spdlog {
 | 
			
		||||
namespace sinks {
 | 
			
		||||
 | 
			
		||||
template<typename Mutex>
 | 
			
		||||
SPDLOG_INLINE basic_file_sink<Mutex>::basic_file_sink(const filename_t &filename, bool truncate)
 | 
			
		||||
{
 | 
			
		||||
    file_helper_.open(filename, truncate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Mutex>
 | 
			
		||||
SPDLOG_INLINE const filename_t &basic_file_sink<Mutex>::filename() const
 | 
			
		||||
{
 | 
			
		||||
    return file_helper_.filename();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Mutex>
 | 
			
		||||
SPDLOG_INLINE void basic_file_sink<Mutex>::sink_it_(const details::log_msg &msg)
 | 
			
		||||
{
 | 
			
		||||
    fmt::memory_buffer formatted;
 | 
			
		||||
    sink::formatter_->format(msg, formatted);
 | 
			
		||||
    file_helper_.write(formatted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Mutex>
 | 
			
		||||
SPDLOG_INLINE void basic_file_sink<Mutex>::flush_()
 | 
			
		||||
{
 | 
			
		||||
    file_helper_.flush();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace sinks
 | 
			
		||||
} // namespace spdlog
 | 
			
		||||
@@ -23,28 +23,12 @@ template<typename Mutex>
 | 
			
		||||
class basic_file_sink final : public base_sink<Mutex>
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    explicit basic_file_sink(const filename_t &filename, bool truncate = false)
 | 
			
		||||
    {
 | 
			
		||||
        file_helper_.open(filename, truncate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const filename_t &filename() const
 | 
			
		||||
    {
 | 
			
		||||
        return file_helper_.filename();
 | 
			
		||||
    }
 | 
			
		||||
    explicit basic_file_sink(const filename_t &filename, bool truncate = false);
 | 
			
		||||
    const filename_t &filename() const;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    void sink_it_(const details::log_msg &msg) override
 | 
			
		||||
    {
 | 
			
		||||
        fmt::memory_buffer formatted;
 | 
			
		||||
        sink::formatter_->format(msg, formatted);
 | 
			
		||||
        file_helper_.write(formatted);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void flush_() override
 | 
			
		||||
    {
 | 
			
		||||
        file_helper_.flush();
 | 
			
		||||
    }
 | 
			
		||||
    void sink_it_(const details::log_msg &msg) override;
 | 
			
		||||
    void flush_() override;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    details::file_helper file_helper_;
 | 
			
		||||
@@ -71,3 +55,7 @@ inline std::shared_ptr<logger> basic_logger_st(const std::string &logger_name, c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace spdlog
 | 
			
		||||
 | 
			
		||||
#ifdef SPDLOG_HEADER_ONLY
 | 
			
		||||
#include "basic_file_sink-inl.h"
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user