Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
6d5bce46
Commit
6d5bce46
authored
May 05, 2016
by
Gabi Melman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "CMake script improvements"
parent
14dd584c
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
25 additions
and
291 deletions
+25
-291
.gitmodules
.gitmodules
+0
-12
CMakeLists.txt
CMakeLists.txt
+2
-15
CMakeLists.txt
bench/CMakeLists.txt
+0
-73
easylogging-bench-mt.cpp
bench/easylogging-bench-mt.cpp
+1
-1
easylogging-bench.cpp
bench/easylogging-bench.cpp
+1
-1
g3log-async.cpp
bench/g3log-async.cpp
+0
-63
zf_log-bench-mt.cpp
bench/zf_log-bench-mt.cpp
+2
-2
zf_log-bench.cpp
bench/zf_log-bench.cpp
+2
-2
CMakeLists.txt
example/CMakeLists.txt
+17
-4
stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+0
-1
CMakeLists.txt
tests/CMakeLists.txt
+0
-19
CMakeLists.txt
tests/header_dependencies/CMakeLists.txt
+0
-58
main.c
tests/header_dependencies/main.c
+0
-7
main.cpp
tests/header_dependencies/main.cpp
+0
-4
CMakeLists.txt
vendor/CMakeLists.txt
+0
-25
easyloggingpp
vendor/easyloggingpp
+0
-1
g3log
vendor/g3log
+0
-1
glog
vendor/glog
+0
-1
zf_log
vendor/zf_log
+0
-1
No files found.
.gitmodules
deleted
100644 → 0
View file @
14dd584c
[submodule "vendor/zf_log"]
path = vendor/zf_log
url = https://github.com/wonder-mice/zf_log.git
[submodule "vendor/glog"]
path = vendor/glog
url = https://github.com/google/glog.git
[submodule "vendor/easyloggingpp"]
path = vendor/easyloggingpp
url = https://github.com/easylogging/easyloggingpp.git
[submodule "vendor/g3log"]
path = vendor/g3log
url = https://github.com/KjellKod/g3log.git
CMakeLists.txt
View file @
6d5bce46
...
...
@@ -12,8 +12,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library
(
spdlog INTERFACE
)
option
(
SPDLOG_BUILD_EXAMPLES
"Build examples"
OFF
)
option
(
SPDLOG_BUILD_TESTS
"Build tests"
OFF
)
option
(
SPDLOG_BUILD_BENCHMARKS
"Build comparison benchmarks for various logging libraries"
OFF
)
target_include_directories
(
spdlog
...
...
@@ -22,20 +20,9 @@ target_include_directories(
"$<INSTALL_INTERFACE:include>"
)
set
(
HEADER_BASE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
include
(
CTest
)
if
(
SPDLOG_BUILD_EXAMPLES
)
add_subdirectory
(
example
)
endif
()
if
(
SPDLOG_BUILD_TESTS
)
add_subdirectory
(
tests
)
endif
()
if
(
SPDLOG_BUILD_BENCHMARKS
)
add_subdirectory
(
vendor
)
add_subdirectory
(
bench
)
enable_testing
()
add_subdirectory
(
example
)
endif
()
### Install ###
...
...
bench/CMakeLists.txt
deleted
100644 → 0
View file @
14dd584c
#
# Benchmarks against various logging systems
#
#
# Dependencies
#
find_package
(
Threads
)
enable_testing
()
# Helper function for building benchmark programs
function
(
add_benchmark _target
)
set
(
options
""
)
# no options
set
(
singleValueArgs
""
)
# no single-value arguments
set
(
multiValueArgs LIBS SOURCES INCLUDES DEFINITIONS
)
# lists of additional libraries, source files, and include directories
cmake_parse_arguments
(
_benchmark
"
${
options
}
"
"
${
singleValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
add_executable
(
${
_target
}
${
_target
}
.cpp
${
_benchmark_SOURCES
}
)
target_include_directories
(
${
_target
}
PUBLIC
${
HEADER_BASE
}
${
_benchmark_INCLUDES
}
)
target_link_libraries
(
${
_target
}
${
CMAKE_THREAD_LIBS_INIT
}
${
_benchmark_LIBS
}
)
if
(
_benchmark_DEFINITIONS
)
target_compile_definitions
(
${
_target
}
PUBLIC
${
_benchmark_DEFINITIONS
}
)
endif
()
add_test
(
NAME test_benchmark_
${
_target
}
COMMAND
${
_target
}
)
endfunction
()
# Benchmark programs
add_benchmark
(
spdlog-bench
)
add_benchmark
(
spdlog-bench-mt
)
add_benchmark
(
spdlog-async
)
if
(
TARGET zf_log
)
add_benchmark
(
zf_log-bench LIBS zf_log
)
add_benchmark
(
zf_log-bench-mt LIBS zf_log
)
endif
()
find_package
(
Boost QUIET COMPONENTS log
)
if
(
Boost_FOUND
)
set
(
BOOST_DEFS
"-DBOOST_LOG_DYN_LINK=1"
)
add_benchmark
(
boost-bench LIBS
${
Boost_LIBRARIES
}
INCLUDES
${
Boost_INCLUDE_DIRS
}
DEFINITIONS
${
BOOST_DEFS
}
)
add_benchmark
(
boost-bench-mt LIBS
${
Boost_LIBRARIES
}
INCLUDES
${
Boost_INCLUDE_DIRS
}
DEFINITIONS
${
BOOST_DEFS
}
)
endif
()
if
(
TARGET glog
)
add_benchmark
(
glog-bench LIBS glog
)
add_benchmark
(
glog-bench-mt LIBS glog
)
endif
()
if
(
TARGET g3logger
)
add_benchmark
(
g3log-async LIBS g3logger INCLUDES
"
${
g3log_SOURCE_DIR
}
/src"
)
endif
()
if
(
TARGET easylogging
)
add_benchmark
(
easylogging-bench LIBS easylogging
)
add_benchmark
(
easylogging-bench-mt LIBS easylogging
)
endif
()
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
bench/easylogging-bench-mt.cpp
View file @
6d5bce46
...
...
@@ -9,7 +9,7 @@
#define _ELPP_THREAD_SAFE
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
_
INITIALIZE_EASYLOGGINGPP
using
namespace
std
;
...
...
bench/easylogging-bench.cpp
View file @
6d5bce46
...
...
@@ -6,7 +6,7 @@
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
_
INITIALIZE_EASYLOGGINGPP
int
main
(
int
,
char
*
[])
{
...
...
bench/g3log-async.cpp
deleted
100644 → 0
View file @
14dd584c
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include <g3log/logworker.hpp>
#include <g3log/g3log.hpp>
using
namespace
std
;
template
<
typename
T
>
std
::
string
format
(
const
T
&
value
);
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
thread_count
=
10
;
if
(
argc
>
1
)
thread_count
=
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
auto
g3log
=
g3
::
LogWorker
::
createLogWorker
();
auto
defaultHandler
=
g3log
->
addDefaultLogger
(
argv
[
0
],
"logs"
);
g3
::
initializeLogging
(
g3log
.
get
());
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
while
(
true
)
{
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
LOG
(
INFO
)
<<
"g3log message #"
<<
counter
<<
": This is some text for your pleasure"
;
}
}));
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
};
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
cout
<<
"Threads: "
<<
thread_count
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
}
bench/zf_log-bench-mt.cpp
View file @
6d5bce46
...
...
@@ -9,7 +9,7 @@
const
char
g_path
[]
=
"logs/zf_log.txt"
;
int
g_fd
;
static
void
output_callback
(
const
zf_log_message
*
msg
,
void
*
ar
g
)
static
void
output_callback
(
zf_log_message
*
ms
g
)
{
*
msg
->
p
=
'\n'
;
write
(
g_fd
,
msg
->
buf
,
msg
->
p
-
msg
->
buf
+
1
);
...
...
@@ -25,7 +25,7 @@ int main(int argc, char* argv[])
ZF_LOGE_AUX
(
ZF_LOG_STDERR
,
"Failed to open log file: %s"
,
g_path
);
return
-
1
;
}
ZF_LOG_DEFINE_GLOBAL_OUTPUT
=
{
ZF_LOG_PUT_STD
,
nullptr
,
&
output_callback
}
;
zf_log_set_output_callback
(
ZF_LOG_PUT_STD
,
output_callback
)
;
int
thread_count
=
10
;
if
(
argc
>
1
)
...
...
bench/zf_log-bench.cpp
View file @
6d5bce46
...
...
@@ -4,7 +4,7 @@
const
char
g_path
[]
=
"logs/zf_log.txt"
;
static
FILE
*
g_f
;
static
void
output_callback
(
const
zf_log_message
*
msg
,
void
*
ar
g
)
static
void
output_callback
(
zf_log_message
*
ms
g
)
{
*
msg
->
p
=
'\n'
;
fwrite
(
msg
->
buf
,
msg
->
p
-
msg
->
buf
+
1
,
1
,
g_f
);
...
...
@@ -18,7 +18,7 @@ int main(int, char* [])
ZF_LOGE_AUX
(
ZF_LOG_STDERR
,
"Failed to open log file: %s"
,
g_path
);
return
-
1
;
}
ZF_LOG_DEFINE_GLOBAL_OUTPUT
=
{
ZF_LOG_PUT_STD
,
nullptr
,
&
output_callback
}
;
zf_log_set_output_callback
(
ZF_LOG_PUT_STD
,
output_callback
)
;
const
int
howmany
=
1000000
;
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
...
...
example/CMakeLists.txt
View file @
6d5bce46
...
...
@@ -21,16 +21,29 @@
# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# *************************************************************************/
find_package
(
Threads
)
cmake_minimum_required
(
VERSION 3.0
)
project
(
SpdlogExamples
)
if
(
TARGET spdlog
)
# Part of the main project
add_library
(
spdlog::spdlog ALIAS spdlog
)
else
()
# Stand-alone build
find_package
(
spdlog CONFIG REQUIRED
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
CMAKE_CXX_FLAGS
"--std=c++11 -pthread"
)
set
(
CMAKE_EXE_LIKKER_FLAGS
"-pthread"
)
endif
()
add_executable
(
example example.cpp
)
target_link_libraries
(
example spdlog
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
example spdlog
::spdlog
)
add_executable
(
benchmark bench.cpp
)
target_link_libraries
(
benchmark spdlog
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
benchmark spdlog
::spdlog
)
enable_testing
()
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
add_test
(
NAME RunExample COMMAND example
)
add_test
(
NAME RunBenchmark COMMAND benchmark
)
include/spdlog/sinks/stdout_sinks.h
View file @
6d5bce46
...
...
@@ -5,7 +5,6 @@
#pragma once
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/null_mutex.h>
#include <cstdio>
...
...
tests/CMakeLists.txt
deleted
100644 → 0
View file @
14dd584c
#
# Tests
#
enable_testing
()
# Build Catch unit tests
add_library
(
catch INTERFACE
)
target_include_directories
(
catch INTERFACE
${
CMAKE_CURRENT_SOURCE_DIR
}
)
file
(
GLOB catch_tests LIST_DIRECTORIES false RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*.cpp
)
add_executable
(
catch_tests
${
catch_tests
}
)
target_link_libraries
(
catch_tests spdlog
)
add_test
(
NAME catch_tests COMMAND catch_tests
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
# Ensure headers include their own dependencies
add_subdirectory
(
header_dependencies
)
tests/header_dependencies/CMakeLists.txt
deleted
100644 → 0
View file @
14dd584c
#
# Ensure all headers include all dependencies
#
set
(
IGNORED_HEADERS
""
)
set
(
COMMON_TEST_LIBRARIES spdlog
)
add_custom_target
(
header_dependencies
)
file
(
GLOB_RECURSE headers RELATIVE
"
${
HEADER_BASE
}
"
${
HEADER_BASE
}
/*.h
)
set
(
test_index 0
)
foreach
(
HEADER
${
headers
}
)
# Sample of relevant variables computed here
# HEADER: details/line_logger_impl.h
# symbolname: spdlog_details_line_logger_impl
# Compute symbolname
string
(
REPLACE
".h"
""
symbolname
"
${
HEADER
}
"
)
string
(
MAKE_C_IDENTIFIER
"
${
symbolname
}
"
symbolname
)
list
(
FIND IGNORED_HEADERS
"
${
HEADER
}
"
_index
)
# If we didn't explicitly ignore this and if we built this target
if
(
${
_index
}
EQUAL -1
)
#message(STATUS "${HEADER}: '${symbolname}'")
set
(
extension cpp
)
# Name the test and output file with a number, to dodge Windows path length limits.
# Call it header, instead of test, to avoid polluting the 'executable namespace'
set
(
test_name
"header_
${
extension
}
_
${
test_index
}
"
)
set
(
source_file
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/main.
${
extension
}
"
)
add_executable
(
${
test_name
}
"
${
source_file
}
"
)
target_compile_definitions
(
${
test_name
}
PRIVATE HEADER_TO_TEST=
"
${
HEADER
}
"
)
target_include_directories
(
${
test_name
}
PRIVATE
${
BUILDTREE_HEADER_BASE
}
${
HEADER_BASE
}
)
set_target_properties
(
${
test_name
}
PROPERTIES
FOLDER
"Header dependency tests"
)
target_link_libraries
(
${
test_name
}
PRIVATE
${
COMMON_TEST_LIBRARIES
}
${
LIBRARIES_
${
symbolname
}}
${
LIBRARIES_
${
libname
}}
)
add_test
(
NAME
${
test_name
}
_builds COMMAND
${
test_name
}
)
add_dependencies
(
header_dependencies
${
test_name
}
)
math
(
EXPR test_index
"
${
test_index
}
+ 1"
)
endif
()
endforeach
()
tests/header_dependencies/main.c
deleted
100644 → 0
View file @
14dd584c
#include HEADER_TO_TEST
int
main
(
int
argc
,
char
**
argv
)
{
return
0
;
}
tests/header_dependencies/main.cpp
deleted
100644 → 0
View file @
14dd584c
#include HEADER_TO_TEST
int
main
(
int
argc
,
char
*
argv
[])
{
return
0
;
}
vendor/CMakeLists.txt
deleted
100644 → 0
View file @
14dd584c
#
# External libraries
#
#
# Most of these libraries are used for running comparison benchmarks against
# other logging libraries.
if
(
IS_DIRECTORY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/zf_log"
)
add_subdirectory
(
zf_log
)
endif
()
if
(
IS_DIRECTORY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/glog"
)
add_subdirectory
(
glog
)
endif
()
if
(
IS_DIRECTORY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/easyloggingpp"
)
add_library
(
easylogging INTERFACE
)
set
(
SPDLOG_VENDORED_EASYLOGGING_ROOT
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/easyloggingpp"
CACHE INTERNAL
""
FORCE
)
target_include_directories
(
easylogging INTERFACE
"
${
SPDLOG_VENDORED_EASYLOGGING_ROOT
}
/src"
)
endif
()
if
(
IS_DIRECTORY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/g3log"
)
add_subdirectory
(
g3log
)
endif
()
easyloggingpp
@
f926802d
Subproject commit f926802dfbde716d82b64b8ef3c25b7f0fcfec65
g3log
@
6c1698c4
Subproject commit 6c1698c4f7db6b9e4246ead38051f9866ea3ac06
glog
@
de6149ef
Subproject commit de6149ef8e67b064a433a8b88924fa9f606ad5d5
zf_log
@
4c15e670
Subproject commit 4c15e6704edffdafe289d4b84c2db89009368626
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment