Fix level 4 warnings under VS
This commit is contained in:
		@@ -49,7 +49,7 @@ const char digit_pairs[201] =
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline std::string& fast_itostr(int n, std::string& s, int padding)
 | 
					inline std::string& fast_itostr(int n, std::string& s, size_t padding)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (n == 0)
 | 
					    if (n == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -58,9 +58,9 @@ inline std::string& fast_itostr(int n, std::string& s, int padding)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int sign = -(n < 0);
 | 
					    int sign = -(n < 0);
 | 
				
			||||||
    unsigned int val = (n^sign) - sign;
 | 
					    unsigned int val = static_cast<unsigned int>((n^sign) - sign);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int size;
 | 
					    size_t size;
 | 
				
			||||||
    if (val >= 10000)
 | 
					    if (val >= 10000)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (val >= 10000000)
 | 
					        if (val >= 10000000)
 | 
				
			||||||
@@ -111,14 +111,14 @@ inline std::string& fast_itostr(int n, std::string& s, int padding)
 | 
				
			|||||||
    c += size - 1;
 | 
					    c += size - 1;
 | 
				
			||||||
    while (val >= 100)
 | 
					    while (val >= 100)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        int pos = val % 100;
 | 
					        size_t pos = val % 100;
 | 
				
			||||||
        val /= 100;
 | 
					        val /= 100;
 | 
				
			||||||
        *(short*)(c - 1) = *(short*)(digit_pairs + 2 * pos);
 | 
					        *(short*)(c - 1) = *(short*)(digit_pairs + 2 * pos);
 | 
				
			||||||
        c -= 2;
 | 
					        c -= 2;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    while (val > 0)
 | 
					    while (val > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        *c-- = '0' + (val % 10);
 | 
					        *c-- = static_cast<char>('0' + (val % 10));
 | 
				
			||||||
        val /= 10;
 | 
					        val /= 10;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,7 +158,7 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // put int and pad with zeroes if smalled than min_width
 | 
					    // put int and pad with zeroes if smalled than min_width
 | 
				
			||||||
    void put_int(int n, int padding)
 | 
					    void put_int(int n, size_t padding)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::string s;
 | 
					        std::string s;
 | 
				
			||||||
        details::fast_itostr(n, s, padding);
 | 
					        details::fast_itostr(n, s, padding);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,7 @@ public:
 | 
				
			|||||||
        _flush_countdown(flush_inverval) {};
 | 
					        _flush_countdown(flush_inverval) {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    file_helper(const file_helper&) = delete;
 | 
					    file_helper(const file_helper&) = delete;
 | 
				
			||||||
 | 
					    file_helper& operator=(const file_helper&) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ~file_helper()
 | 
					    ~file_helper()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,7 @@ inline int utc_minutes_offset(const std::tm& tm = localtime())
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
 | 
					    (void)tm; // avoid unused param warning
 | 
				
			||||||
    DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
 | 
					    DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
 | 
				
			||||||
    auto rv = GetDynamicTimeZoneInformation(&tzinfo);
 | 
					    auto rv = GetDynamicTimeZoneInformation(&tzinfo);
 | 
				
			||||||
    if (!rv)
 | 
					    if (!rv)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ namespace details
 | 
				
			|||||||
class flag_formatter
 | 
					class flag_formatter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    virtual ~flag_formatter() {}
 | 
				
			||||||
    virtual void format(details::log_msg& msg) = 0;
 | 
					    virtual void format(details::log_msg& msg) = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -295,6 +296,9 @@ class T_formatter :public flag_formatter
 | 
				
			|||||||
class z_formatter :public flag_formatter
 | 
					class z_formatter :public flag_formatter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    z_formatter() {}
 | 
				
			||||||
 | 
					    z_formatter(const z_formatter&) = delete;
 | 
				
			||||||
 | 
					    z_formatter& operator=(const z_formatter&) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void format(log_msg& msg) override
 | 
					    void format(log_msg& msg) override
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -312,6 +316,8 @@ public:
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
    log_clock::time_point _last_update;
 | 
					    log_clock::time_point _last_update;
 | 
				
			||||||
    std::string _value;
 | 
					    std::string _value;
 | 
				
			||||||
 | 
					    std::mutex _mutex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string get_value(const log_msg& msg)
 | 
					    std::string get_value(const log_msg& msg)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        int total_minutes = os::utc_minutes_offset(msg.tm_time);
 | 
					        int total_minutes = os::utc_minutes_offset(msg.tm_time);
 | 
				
			||||||
@@ -324,7 +330,7 @@ private:
 | 
				
			|||||||
        oss.put_int(m, 2);
 | 
					        oss.put_int(m, 2);
 | 
				
			||||||
        return oss.str();
 | 
					        return oss.str();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::mutex _mutex;
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -451,7 +457,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    switch (flag)
 | 
					    switch (flag)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // logger name
 | 
					    // logger name
 | 
				
			||||||
    case 'n':
 | 
					    case 'n':
 | 
				
			||||||
        _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
 | 
					        _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -122,6 +122,7 @@ public:
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
    registry() = default;
 | 
					    registry() = default;
 | 
				
			||||||
    registry(const registry&) = delete;
 | 
					    registry(const registry&) = delete;
 | 
				
			||||||
 | 
					    registry& operator=(const registry&) = delete;
 | 
				
			||||||
    std::mutex _mutex;
 | 
					    std::mutex _mutex;
 | 
				
			||||||
    std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
 | 
					    std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
 | 
				
			||||||
    formatter_ptr _formatter;
 | 
					    formatter_ptr _formatter;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,7 @@ class pattern_formatter : public formatter
 | 
				
			|||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit pattern_formatter(const std::string& pattern);
 | 
					    explicit pattern_formatter(const std::string& pattern);
 | 
				
			||||||
    pattern_formatter(const pattern_formatter&) = delete;
 | 
					    pattern_formatter(const pattern_formatter&) = delete;
 | 
				
			||||||
 | 
					    pattern_formatter& operator=(const pattern_formatter&) = delete;
 | 
				
			||||||
    void format(details::log_msg& msg) override;
 | 
					    void format(details::log_msg& msg) override;
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    const std::string _pattern;
 | 
					    const std::string _pattern;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user