Fix Unix build. Use S("...") instead of L"..." for better compatibility.
This commit is contained in:
		@@ -39,8 +39,9 @@
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
typedef std::wstring tstring;
 | 
			
		||||
typedef wchar_t tchar;
 | 
			
		||||
#define S(s) L ## s
 | 
			
		||||
#else
 | 
			
		||||
#define L
 | 
			
		||||
#define S(s) s
 | 
			
		||||
typedef std::string tstring;
 | 
			
		||||
typedef char tchar;
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -2638,6 +2638,12 @@ public:
 | 
			
		||||
typedef BasicMemoryWriter<char> MemoryWriter;
 | 
			
		||||
typedef BasicMemoryWriter<wchar_t> WMemoryWriter;
 | 
			
		||||
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
#define TMemoryWriter WMemoryWriter
 | 
			
		||||
#else
 | 
			
		||||
#define TMemoryWriter MemoryWriter
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
\rst
 | 
			
		||||
This class template provides operations for formatting and writing data
 | 
			
		||||
@@ -2648,11 +2654,6 @@ Any write method will throw ``std::runtime_error`` if the output doesn't fit
 | 
			
		||||
into the array.
 | 
			
		||||
 | 
			
		||||
You can use one of the following typedefs for common character types:
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
#define TMemoryWriter WMemoryWriter
 | 
			
		||||
#else
 | 
			
		||||
#define TMemoryWriter MemoryWriter
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
+--------------+---------------------------+
 | 
			
		||||
| Type         | Definition                |
 | 
			
		||||
 
 | 
			
		||||
@@ -147,7 +147,7 @@ constexpr inline unsigned short eol_size()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//fopen_s on non windows for writing
 | 
			
		||||
inline int fopen_s(FILE** fp, const tstring& filename, tchar* mode)
 | 
			
		||||
inline int fopen_s(FILE** fp, const tstring& filename, const tchar* mode)
 | 
			
		||||
{
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    *fp = _wfsopen((filename.c_str()), mode, _SH_DENYWR);
 | 
			
		||||
@@ -172,7 +172,7 @@ inline int rename(const tchar* filename1, const tchar* filename2)
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    return _wrename(filename1, filename2);
 | 
			
		||||
#else
 | 
			
		||||
    return std::remove(filename1, filename2);
 | 
			
		||||
    return std::remove(filename1);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,22 +50,22 @@ inline void spdlog::drop(const std::string &name)
 | 
			
		||||
// Create multi/single threaded rotating file logger
 | 
			
		||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const tstring& filename, size_t max_file_size, size_t max_files, bool force_flush)
 | 
			
		||||
{
 | 
			
		||||
    return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, L"txt", max_file_size, max_files, force_flush);
 | 
			
		||||
    return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, S("txt"), max_file_size, max_files, force_flush);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const tstring& filename, size_t max_file_size, size_t max_files, bool force_flush)
 | 
			
		||||
{
 | 
			
		||||
    return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, L"txt", max_file_size, max_files, force_flush);
 | 
			
		||||
    return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, S("txt"), max_file_size, max_files, force_flush);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create file logger which creates new file at midnight):
 | 
			
		||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const tstring& filename, int hour, int minute, bool force_flush)
 | 
			
		||||
{
 | 
			
		||||
    return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, L"txt", hour, minute, force_flush);
 | 
			
		||||
    return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, S("txt"), hour, minute, force_flush);
 | 
			
		||||
}
 | 
			
		||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const tstring& filename, int hour, int minute, bool force_flush)
 | 
			
		||||
{
 | 
			
		||||
    return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, L"txt", hour, minute, force_flush);
 | 
			
		||||
    return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, S("txt"), hour, minute, force_flush);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -107,9 +107,9 @@ private:
 | 
			
		||||
    {
 | 
			
		||||
        fmt::TMemoryWriter w;
 | 
			
		||||
        if (index)
 | 
			
		||||
            w.write(L"{}.{}.{}", filename, index, extension);
 | 
			
		||||
            w.write(S("{}.{}.{}"), filename, index, extension);
 | 
			
		||||
        else
 | 
			
		||||
            w.write(L"{}.{}", filename, extension);
 | 
			
		||||
            w.write(S("{}.{}"), filename, extension);
 | 
			
		||||
        return w.str();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -215,7 +215,7 @@ private:
 | 
			
		||||
    {
 | 
			
		||||
        std::tm tm = spdlog::details::os::localtime();
 | 
			
		||||
        fmt::TMemoryWriter w;
 | 
			
		||||
        w.write(L"{}_{:04d}-{:02d}-{:02d}_{:02d}-{:02d}.{}", basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, extension);
 | 
			
		||||
        w.write(S("{}_{:04d}-{:02d}-{:02d}_{:02d}-{:02d}.{}"), basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, extension);
 | 
			
		||||
        return w.str();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user