Skip to content

Commit 5a435c3

Browse files
committed
Move logging to separate repository.
0 parents  commit 5a435c3

File tree

19 files changed

+687
-0
lines changed

19 files changed

+687
-0
lines changed

.build_conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
export cmake_var_tests="${cmake_var_tests:-"-DEXTLOG_TESTS=ON"}"
3+
export cmake_var_examples="${cmake_var_examples:-"-DEXTLOG_EXAMPLES=ON"}"
4+
echo "ext-logging - project_root: $project_root"

.clang_complete

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-I
2+
include
3+
-I
4+
external_libs/ext-basics/include

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
current-build-dir
3+
support

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "ext-basics"]
2+
path = external_libs/ext-basics
3+
url = https://github.com/extcpp/basics.git
4+
[submodule "cmake"]
5+
path = cmake
6+
url = https://github.com/extcpp/cmake.git

CMakeLists.txt

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Copyright - 2016-2020 - Jan Christoph Uhde <[email protected]>
2+
3+
cmake_minimum_required(VERSION 3.8)
4+
project(ext-logging VERSION 0.0.1 LANGUAGES CXX)
5+
message(STATUS "extINFO -- entering ext-logging")
6+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
7+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8+
9+
## OPTIONS
10+
option(EXTLOG_EXAMPLES "build examples" OFF)
11+
option(EXTLOG_WARNINGS "enable warnings" ON)
12+
option(EXTLOG_CHECKED "user assert" ON)
13+
option(EXTLOG_TESTS "build tests" OFF)
14+
15+
## general setup and includes
16+
set(CMAKE_CXX_STANDARD 17)
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18+
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # XCode / VS folders
19+
20+
set(LIBEXT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_libs/ext-basics)
21+
include(ext_cmake_setup)
22+
include(ext_cmake_install)
23+
24+
find_package(Threads REQUIRED)
25+
if(NOT TARGET ext::basics)
26+
add_subdirectory(external_libs/ext-basics EXCLUDE_FROM_ALL)
27+
endif()
28+
29+
set(FORCE_COLORED_OUTPUT ON)
30+
ext_colored_compiler_ouput()
31+
32+
# verbose windows linking
33+
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /VERBOSE:LIB")
34+
35+
if(LINUX)
36+
set(EXT_OUTDIR "")
37+
elseif(MSVC)
38+
#TODO - move settings below into corresponding targets
39+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${EXT_OUTDIR}")
40+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${EXT_OUTDIR}")
41+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${EXT_OUTDIR}")
42+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
43+
endif()
44+
45+
# include build dir to find version.hpp
46+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
47+
48+
# required by folder structure for XCode and VisualStudio (includes)
49+
# sources are always required
50+
include(src_files.cmake)
51+
include(include_files.cmake)
52+
53+
### library setup
54+
set(ext_common_compile_definitions
55+
$<IF:$<BOOL:${ext_is_big_endian}>,EXT_BIG_ENDIAN,EXT_LITTLE_ENDIAN>
56+
$<$<BOOL:${EXT_CXX_COMPILER_IS_GCC}>:EXT_GCC>
57+
$<$<BOOL:${EXT_CXX_COMPILER_IS_CLANG}>:EXT_CLANG>
58+
$<$<BOOL:${ext_l1_cache_line_size}>:EXT_KNOWN_L1_CACHE_LINE_SIZE=${ext_l1_cache_line_size}>
59+
)
60+
61+
62+
add_library(ext-logging ${ext-logging-source} ${ext-logging-header})
63+
target_include_directories(ext-logging PUBLIC
64+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
65+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
66+
)
67+
target_compile_features(ext-logging PUBLIC cxx_std_17)
68+
target_compile_options(ext-logging PRIVATE ${ext_stone-warnings})
69+
target_compile_definitions(ext-logging PUBLIC ${ext_common_compile_definitions})
70+
target_compile_definitions(ext-logging PUBLIC EXT_SHARED_LIB)
71+
target_compile_definitions(ext-logging PRIVATE EXT_IN_LIB=1)
72+
target_link_libraries(ext-logging PUBLIC ext::basics Threads::Threads)
73+
74+
# set up folder structure for XCode and VisualStudio
75+
set_target_properties (ext-logging PROPERTIES FOLDER logging)
76+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${ext-logging-header} ${ext-logging-source})
77+
78+
add_library(ext::logging ALIAS ext-logging)
79+
80+
## testing
81+
if(EXTLOG_TESTS)
82+
ext_log("ext-logging tests enabled")
83+
include(CTest)
84+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
85+
ext_add_test_subdirectory("google" tests)
86+
else()
87+
ext_log("ext-logging tests disabled")
88+
endif()
89+
90+
## add projects using this lib
91+
if(EXTLOG_EXAMPLES)
92+
ext_log("ext-logging examples enabled")
93+
add_subdirectory(examples)
94+
else()
95+
ext_log("ext-logging examples disabled")
96+
endif()
97+
98+
## installation
99+
if(COMMAND ext_install)
100+
set_target_properties(ext-logging PROPERTIES EXPORT_NAME logging)
101+
102+
ext_install(ext-logging include/ext)
103+
104+
install(TARGETS ext-logging
105+
EXPORT ext-logging-targets
106+
DESTINATION ${CMAKE_INSTALL_PREFIX}
107+
)
108+
install(
109+
EXPORT ext-logging-targets
110+
FILE ext-logging-config.cmake
111+
NAMESPACE ext::
112+
DESTINATION ${CMAKE_INSTALL_PREFIX}
113+
)
114+
endif()
115+
116+
add_custom_target(
117+
update_logging_version ALL
118+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
119+
COMMAND ${CMAKE_COMMAND}
120+
-D "EXT_GIT_VERSION_OUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/ext_version.hpp"
121+
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ext_script_git_version.cmake"
122+
)

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WIP
2+
===

cmake

Submodule cmake added at 231d089

examples/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright - 2016-2020 - Jan Christoph Uhde <[email protected]>
2+
3+
cmake_minimum_required(VERSION 3.0.0)
4+
project(ext-logging-examples)
5+
6+
## examples
7+
set(examples
8+
logging
9+
)
10+
11+
foreach(ex IN LISTS examples) # <- DO NOT EXPAND LIST
12+
set(cpp "${ex}.cpp")
13+
set(example "${ex}_example")
14+
add_executable(${example} ${cpp})
15+
target_link_libraries(${example}
16+
${CMAKE_THREAD_LIBS_INIT}
17+
ext::logging
18+
)
19+
target_compile_options(${example} PRIVATE ${ext_stone-warnings})
20+
set_target_properties (${example} PROPERTIES FOLDER examples/${example})
21+
endforeach()

examples/logging.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright - 2020 - Jan Christoph Uhde <[email protected]>
2+
// Please see LICENSE.md for license or visit https://github.com/extcpp/basics
3+
#include <iostream>
4+
#include <map>
5+
#include <vector>
6+
7+
#ifndef _WIN32
8+
#include <ext/logging.hpp>
9+
10+
int main(/*int argc, const char *argv[]*/) {
11+
{
12+
using namespace ext::logging;
13+
configuration::function = false;
14+
configuration::append_newline = true;
15+
}
16+
17+
EXT_DEV << "geil";
18+
EXT_DEVV << "ballern";
19+
20+
EXT_LOG("mic", info) << "1"
21+
<< "2"
22+
<< "3";
23+
24+
EXT_LOG("cafe") << "default level and topic";
25+
EXT_LOG("0000", trace) << "where is the byte gone";
26+
EXT_LOG("1111", network, debug) << "ohlala";
27+
EXT_LOG("2222", info) << "Hi there!";
28+
EXT_LOG_STATIC("3333", warn) << "something is wrong";
29+
EXT_LOG_STATIC("4444", network, error, false) << "your network is broken";
30+
EXT_LOG_STATIC("5555", network, error, true) << "your network is broken";
31+
EXT_LOG("6666", fatal) << "your app will terminate";
32+
33+
#else
34+
int main(/*int argc, const char *argv[]*/) {
35+
#endif // _WIN32
36+
return 0;
37+
}

external_libs/ext-basics

Submodule ext-basics added at 69bf759

0 commit comments

Comments
 (0)