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