Squashed 'libs/CommService/' content from commit 7ccc0fc

git-subtree-dir: libs/CommService
git-subtree-split: 7ccc0fce88bbc5969df060058cf0fb57abe3bcf9
This commit is contained in:
Henry Winkel
2022-09-15 09:53:53 +02:00
commit cc67e4840f
799 changed files with 179487 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 2.8)
project(loguru_example)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -pedantic")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-noreturn")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-disabled-macro-expansion")
endif() # Clang
file(GLOB source
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/../*.cpp"
)
add_executable(loguru_example ${source})
find_package(Threads)
target_link_libraries(loguru_example ${CMAKE_THREAD_LIBS_INIT}) # For pthreads
if(NOT WIN32)
target_link_libraries(loguru_example dl) # For ldl
endif()

View File

@@ -0,0 +1,12 @@
#!/bin/bash
set -e # Fail on error
ROOT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
cd "$ROOT_DIR"
mkdir -p build
cd build
cmake ..
make
./loguru_example $@

View File

@@ -0,0 +1,26 @@
#include <chrono>
#include <thread>
#include "../loguru.hpp"
inline void sleep_ms(int ms)
{
VLOG_F(2, "Sleeping for %d ms", ms);
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
inline void complex_calculation()
{
LOG_SCOPE_F(INFO, "complex_calculation");
LOG_F(INFO, "Starting time machine...");
sleep_ms(200);
LOG_F(WARNING, "The flux capacitor is not getting enough power!");
sleep_ms(400);
LOG_F(INFO, "Lighting strike!");
VLOG_F(1, "Found 1.21 gigawatts...");
sleep_ms(400);
std::thread([](){
loguru::set_thread_name("the past");
LOG_F(ERROR, "We ended up in 1985!");
}).join();
}

View File

@@ -0,0 +1,13 @@
#include <iostream>
#include "loguru_example.hpp"
#include "../loguru.cpp"
int main(int argc, char* argv[])
{
loguru::init(argc, argv);
LOG_F(INFO, "Hello from main.cpp!");
complex_calculation();
LOG_F(INFO, "main function about to end!");
}