mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
Fixed issue #798 and added -Wconversion compiler flag to build
This commit is contained in:
parent
06181720fb
commit
a58d7594cb
@ -28,7 +28,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
add_compile_options("-Wall")
|
||||
add_compile_options("-Wextra")
|
||||
add_compile_options("-Wconversion")
|
||||
add_compile_options("-pedantic")
|
||||
|
||||
endif()
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
|
@ -35,8 +35,8 @@ int main(int argc, char *argv[])
|
||||
int howmany = 1000000;
|
||||
int queue_size = howmany + 2;
|
||||
int threads = 10;
|
||||
int file_size = 30 * 1024 * 1024;
|
||||
int rotating_files = 5;
|
||||
size_t file_size = 30 * 1024 * 1024;
|
||||
size_t rotating_files = 5;
|
||||
|
||||
try
|
||||
{
|
||||
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
spdlog::init_thread_pool(queue_size, 1);
|
||||
spdlog::init_thread_pool(static_cast<size_t>(queue_size), 1);
|
||||
auto as = spdlog::basic_logger_mt<spdlog::async_factory>("async", "logs/basic_async.log", true);
|
||||
bench_mt(howmany, as, threads);
|
||||
spdlog::drop("async");
|
||||
|
@ -35,8 +35,8 @@ int main(int, char *[])
|
||||
int howmany = 1000000;
|
||||
int queue_size = howmany + 2;
|
||||
int threads = 10;
|
||||
int file_size = 30 * 1024 * 1024;
|
||||
int rotating_files = 5;
|
||||
size_t file_size = 30 * 1024 * 1024;
|
||||
size_t rotating_files = 5;
|
||||
|
||||
try
|
||||
{
|
||||
@ -82,7 +82,7 @@ int main(int, char *[])
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
spdlog::init_thread_pool(queue_size, 1);
|
||||
spdlog::init_thread_pool(static_cast<size_t>(queue_size), 1);
|
||||
auto as = spdlog::basic_logger_mt<spdlog::async_factory>("async", "logs/basic_async.log", true);
|
||||
bench_mt(howmany, as, threads);
|
||||
spdlog::drop("async");
|
||||
|
@ -1,5 +1,5 @@
|
||||
CXX ?= g++
|
||||
CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1
|
||||
CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1 -Wconversion
|
||||
CXX_RELEASE_FLAGS = -O3 -march=native
|
||||
CXX_DEBUG_FLAGS= -g
|
||||
|
||||
|
@ -54,14 +54,14 @@ inline void pad2(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
|
||||
}
|
||||
if (n > 9) // 10-99
|
||||
{
|
||||
dest.push_back('0' + static_cast<char>(n / 10));
|
||||
dest.push_back('0' + static_cast<char>(n % 10));
|
||||
dest.push_back(static_cast<char>('0' + n / 10));
|
||||
dest.push_back(static_cast<char>('0' + n % 10));
|
||||
return;
|
||||
}
|
||||
if (n >= 0) // 0-9
|
||||
{
|
||||
dest.push_back('0');
|
||||
dest.push_back('0' + static_cast<char>(n));
|
||||
dest.push_back(static_cast<char>('0' + n));
|
||||
return;
|
||||
}
|
||||
// negatives (unlikely, but just in case, let fmt deal with it)
|
||||
@ -86,15 +86,15 @@ inline void pad3(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
|
||||
if (n > 9) // 10-99
|
||||
{
|
||||
dest.push_back('0');
|
||||
dest.push_back('0' + static_cast<char>(n / 10));
|
||||
dest.push_back('0' + static_cast<char>(n % 10));
|
||||
dest.push_back(static_cast<char>('0' + n / 10));
|
||||
dest.push_back(static_cast<char>('0' + n % 10));
|
||||
return;
|
||||
}
|
||||
if (n >= 0)
|
||||
{
|
||||
dest.push_back('0');
|
||||
dest.push_back('0');
|
||||
dest.push_back('0' + static_cast<char>(n));
|
||||
dest.push_back(static_cast<char>('0' + n));
|
||||
return;
|
||||
}
|
||||
// negatives (unlikely, but just in case let fmt deal with it)
|
||||
|
@ -30,7 +30,7 @@ protected:
|
||||
{
|
||||
fmt::memory_buffer formatted;
|
||||
sink::formatter_->format(msg, formatted);
|
||||
ostream_.write(formatted.data(), formatted.size());
|
||||
ostream_.write(formatted.data(), static_cast<std::streamsize>(formatted.size()));
|
||||
if (force_flush_)
|
||||
ostream_.flush();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
CXX ?= g++
|
||||
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -O3 -I../include -fmax-errors=1
|
||||
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -Wconversion -O3 -I../include -fmax-errors=1
|
||||
LDPFALGS = -pthread
|
||||
|
||||
CPP_FILES := $(wildcard *.cpp)
|
||||
|
@ -9,7 +9,7 @@ TEST_CASE("register_drop", "[registry]")
|
||||
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name);
|
||||
REQUIRE(spdlog::get(tested_logger_name) != nullptr);
|
||||
// Throw if registring existing name
|
||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), const spdlog::spdlog_ex&);
|
||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), const spdlog::spdlog_ex &);
|
||||
}
|
||||
|
||||
TEST_CASE("explicit register"
|
||||
@ -20,7 +20,7 @@ TEST_CASE("explicit register"
|
||||
spdlog::register_logger(logger);
|
||||
REQUIRE(spdlog::get(tested_logger_name) != nullptr);
|
||||
// Throw if registring existing name
|
||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), const spdlog::spdlog_ex&);
|
||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), const spdlog::spdlog_ex &);
|
||||
}
|
||||
|
||||
TEST_CASE("apply_all"
|
||||
|
Loading…
Reference in New Issue
Block a user