Merge branch 'master' into to_level

This commit is contained in:
Fernando Gomes 2018-02-05 09:52:30 -02:00 committed by GitHub
commit f4ffddc942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 20 deletions

View File

@ -64,9 +64,9 @@ int main(int, char*[])
// Runtime log levels
spd::set_level(spd::level::info); //Set global log level to info
console->debug("This message shold not be displayed!");
console->debug("This message should not be displayed!");
console->set_level(spd::level::debug); // Set specific logger's log level
console->debug("This message shold be displayed..");
console->debug("This message should be displayed..");
// Compile time log levels
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON

View File

@ -112,7 +112,7 @@ inline spdlog::level::level_enum to_level_enum(const char* name)
}
return (spdlog::level::level_enum) 0;
}
using level_hasher = std::hash<int>;
} //level

View File

@ -10,7 +10,7 @@
#include "../details/os.h"
#include <string>
#include <map>
#include <unordered_map>
namespace spdlog
{
@ -104,7 +104,7 @@ protected:
}
FILE* target_file_;
bool should_do_colors_;
std::map<level::level_enum, std::string> colors_;
std::unordered_map<level::level_enum, std::string, level::level_hasher> colors_;
};

View File

@ -11,7 +11,7 @@
#include <mutex>
#include <string>
#include <map>
#include <unordered_map>
#include <wincon.h>
namespace spdlog
@ -73,7 +73,7 @@ protected:
private:
HANDLE out_handle_;
std::map<level::level_enum, WORD> colors_;
std::unordered_map<level::level_enum, WORD, level::level_hasher> colors_;
// set color and return the orig console attributes (for resetting later)
WORD set_console_attribs(WORD attribs)

View File

@ -1,19 +1,23 @@
#
# Tests
#
project(spdlog-utests)
enable_testing()
find_package(Threads REQUIRED)
find_package(Threads)
set(SPDLOG_UTESTS_SOURCES
errors.cpp
file_helper.cpp
file_log.cpp
format.cpp
includes.h
registry.cpp
test_macros.cpp
utils.cpp
utils.h
main.cpp)
# Build Catch unit tests
add_library(catch INTERFACE)
target_include_directories(catch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog)
file(GLOB catch_tests LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h *.hpp)
add_executable(catch_tests ${catch_tests})
target_link_libraries(catch_tests spdlog ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME catch_tests COMMAND catch_tests)
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")