Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
with:
submodules: 'recursive'

- name: Install ninja-build
run: |
brew install ninja
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }} -DLOGCOE_BUILD_TESTS=ON
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ jobs:
with:
submodules: 'recursive'

- name: Install Windows build tools
if: matrix.compiler != 'msvc'
run: |
choco install mingw
shell: bash

- name: Install Ninja
if: matrix.compiler == 'msvc'
run: |
choco install ninja
shell: bash

- name: Setup MSVC dev environment
if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1.13.0
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ target_include_directories(logcoe

include(cmake/utils.cmake)

enable_strict_warnings(logcoe)

option(LOGCOE_BUILD_TESTS "Build the logcoe test suite" OFF)
if(LOGCOE_BUILD_TESTS)
add_subdirectory(tests)
Expand Down
8 changes: 8 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ function(ignore_external_warnings target_name)
message(WARNING "Target ${target_name} not found")
endif()
endfunction()

function(enable_strict_warnings target_name)
if(MSVC)
target_compile_options(${target_name} PRIVATE /W4 /WX)
else()
target_compile_options(${target_name} PRIVATE -Werror -Wall -Wextra -Wpedantic)
endif()
endfunction()
19 changes: 9 additions & 10 deletions src/logcoe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,24 @@ namespace
namespace logcoe
{
#ifdef NDEBUG
void initialize(LogLevel level, const std::string &defaultSource, bool enableConsole,
bool enableFile, const std::string &filename) { }
void initialize(LogLevel, const std::string &, bool, bool, const std::string &) { }

void shutdown() { }

void setLogLevel(LogLevel level) { }
void setConsoleOutput(std::ostream &stream) { }
bool setFileOutput(const std::string &filename) { return false; }
void setLogLevel(LogLevel) { }
void setConsoleOutput(std::ostream &) { }
bool setFileOutput(const std::string &) { return false; }
void disableConsoleOutput() { }
void disableFileOutput() { }
void setTimeFormat(const std::string &format) { }
void setTimeFormat(const std::string &) { }

bool isInitialized() { return false; }
LogLevel getLogLevel() { return LogLevel::NONE; }

void debug(const std::string &message, const std::string &source, bool flush) { }
void info(const std::string &message, const std::string &source, bool flush) { }
void warning(const std::string &message, const std::string &source, bool flush) { }
void error(const std::string &message, const std::string &source, bool flush) { }
void debug(const std::string &, const std::string &, bool) { }
void info(const std::string &, const std::string &, bool) { }
void warning(const std::string &, const std::string &, bool) { }
void error(const std::string &, const std::string &, bool) { }
void flush() { }
#else
void initialize(LogLevel level, const std::string &defaultSource, bool enableConsole,
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ target_link_libraries(logcoe_tests
testcoe
)

enable_strict_warnings(logcoe_tests)

add_custom_target(run_logcoe_tests
COMMAND logcoe_tests
DEPENDS logcoe_tests
Expand All @@ -36,6 +38,8 @@ target_link_libraries(logcoe_strip_tests
testcoe
)

enable_strict_warnings(logcoe_strip_tests)

add_custom_target(run_logcoe_strip_tests
COMMAND logcoe_strip_tests
DEPENDS logcoe_strip_tests
Expand Down
6 changes: 3 additions & 3 deletions tests/logcoe_thread_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ TEST_F(LogcoeThreadTest, ConcurrentLogLevelChange)
std::vector<std::thread> threads;
std::atomic<bool> start_flag(false);

threads.emplace_back([this, &start_flag]()
threads.emplace_back([&start_flag]()
{
while (!start_flag.load())
{
Expand All @@ -185,7 +185,7 @@ TEST_F(LogcoeThreadTest, ConcurrentLogLevelChange)

for (int level = 0; level < 3; level++)
{
threads.emplace_back([this, level, &start_flag]()
threads.emplace_back([level, &start_flag]()
{
while (!start_flag.load())
{
Expand Down Expand Up @@ -264,7 +264,7 @@ TEST_F(LogcoeThreadTest, ConcurrentOutputConfigChange)
}
});

threads.emplace_back([this, &start_flag]()
threads.emplace_back([&start_flag]()
{
while (!start_flag.load())
{
Expand Down
Loading