Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
a58d7594
Commit
a58d7594
authored
Aug 17, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #798 and added -Wconversion compiler flag to build
parent
06181720
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
17 deletions
+19
-17
CMakeLists.txt
CMakeLists.txt
+2
-0
bench/bench.cpp
bench/bench.cpp
+3
-3
bench/latency.cpp
bench/latency.cpp
+3
-3
example/Makefile
example/Makefile
+1
-1
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+6
-6
include/spdlog/sinks/ostream_sink.h
include/spdlog/sinks/ostream_sink.h
+1
-1
tests/Makefile
tests/Makefile
+1
-1
tests/registry.cpp
tests/registry.cpp
+2
-2
No files found.
CMakeLists.txt
View file @
a58d7594
...
@@ -28,7 +28,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
...
@@ -28,7 +28,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
add_compile_options
(
"-Wall"
)
add_compile_options
(
"-Wall"
)
add_compile_options
(
"-Wextra"
)
add_compile_options
(
"-Wextra"
)
add_compile_options
(
"-Wconversion"
)
add_compile_options
(
"-pedantic"
)
add_compile_options
(
"-pedantic"
)
endif
()
endif
()
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
...
...
bench/bench.cpp
View file @
a58d7594
...
@@ -35,8 +35,8 @@ int main(int argc, char *argv[])
...
@@ -35,8 +35,8 @@ int main(int argc, char *argv[])
int
howmany
=
1000000
;
int
howmany
=
1000000
;
int
queue_size
=
howmany
+
2
;
int
queue_size
=
howmany
+
2
;
int
threads
=
10
;
int
threads
=
10
;
in
t
file_size
=
30
*
1024
*
1024
;
size_
t
file_size
=
30
*
1024
*
1024
;
in
t
rotating_files
=
5
;
size_
t
rotating_files
=
5
;
try
try
{
{
...
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
...
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
{
spdlog
::
init_thread_pool
(
queue_size
,
1
);
spdlog
::
init_thread_pool
(
static_cast
<
size_t
>
(
queue_size
)
,
1
);
auto
as
=
spdlog
::
basic_logger_mt
<
spdlog
::
async_factory
>
(
"async"
,
"logs/basic_async.log"
,
true
);
auto
as
=
spdlog
::
basic_logger_mt
<
spdlog
::
async_factory
>
(
"async"
,
"logs/basic_async.log"
,
true
);
bench_mt
(
howmany
,
as
,
threads
);
bench_mt
(
howmany
,
as
,
threads
);
spdlog
::
drop
(
"async"
);
spdlog
::
drop
(
"async"
);
...
...
bench/latency.cpp
View file @
a58d7594
...
@@ -35,8 +35,8 @@ int main(int, char *[])
...
@@ -35,8 +35,8 @@ int main(int, char *[])
int
howmany
=
1000000
;
int
howmany
=
1000000
;
int
queue_size
=
howmany
+
2
;
int
queue_size
=
howmany
+
2
;
int
threads
=
10
;
int
threads
=
10
;
in
t
file_size
=
30
*
1024
*
1024
;
size_
t
file_size
=
30
*
1024
*
1024
;
in
t
rotating_files
=
5
;
size_
t
rotating_files
=
5
;
try
try
{
{
...
@@ -82,7 +82,7 @@ int main(int, char *[])
...
@@ -82,7 +82,7 @@ int main(int, char *[])
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
{
spdlog
::
init_thread_pool
(
queue_size
,
1
);
spdlog
::
init_thread_pool
(
static_cast
<
size_t
>
(
queue_size
)
,
1
);
auto
as
=
spdlog
::
basic_logger_mt
<
spdlog
::
async_factory
>
(
"async"
,
"logs/basic_async.log"
,
true
);
auto
as
=
spdlog
::
basic_logger_mt
<
spdlog
::
async_factory
>
(
"async"
,
"logs/basic_async.log"
,
true
);
bench_mt
(
howmany
,
as
,
threads
);
bench_mt
(
howmany
,
as
,
threads
);
spdlog
::
drop
(
"async"
);
spdlog
::
drop
(
"async"
);
...
...
example/Makefile
View file @
a58d7594
CXX
?=
g++
CXX
?=
g++
CXX_FLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c++11
-pthread
-I
../include
-fmax-errors
=
1
CXX_FLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c++11
-pthread
-I
../include
-fmax-errors
=
1
-Wconversion
CXX_RELEASE_FLAGS
=
-O3
-march
=
native
CXX_RELEASE_FLAGS
=
-O3
-march
=
native
CXX_DEBUG_FLAGS
=
-g
CXX_DEBUG_FLAGS
=
-g
...
...
include/spdlog/details/fmt_helper.h
View file @
a58d7594
...
@@ -54,14 +54,14 @@ inline void pad2(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
...
@@ -54,14 +54,14 @@ inline void pad2(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
}
}
if
(
n
>
9
)
// 10-99
if
(
n
>
9
)
// 10-99
{
{
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
/
10
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
/
10
));
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
%
10
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
%
10
));
return
;
return
;
}
}
if
(
n
>=
0
)
// 0-9
if
(
n
>=
0
)
// 0-9
{
{
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
));
return
;
return
;
}
}
// negatives (unlikely, but just in case, let fmt deal with it)
// negatives (unlikely, but just in case, let fmt deal with it)
...
@@ -86,15 +86,15 @@ inline void pad3(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
...
@@ -86,15 +86,15 @@ inline void pad3(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
if
(
n
>
9
)
// 10-99
if
(
n
>
9
)
// 10-99
{
{
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
/
10
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
/
10
));
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
%
10
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
%
10
));
return
;
return
;
}
}
if
(
n
>=
0
)
if
(
n
>=
0
)
{
{
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
+
static_cast
<
char
>
(
n
));
dest
.
push_back
(
static_cast
<
char
>
(
'0'
+
n
));
return
;
return
;
}
}
// negatives (unlikely, but just in case let fmt deal with it)
// negatives (unlikely, but just in case let fmt deal with it)
...
...
include/spdlog/sinks/ostream_sink.h
View file @
a58d7594
...
@@ -30,7 +30,7 @@ protected:
...
@@ -30,7 +30,7 @@ protected:
{
{
fmt
::
memory_buffer
formatted
;
fmt
::
memory_buffer
formatted
;
sink
::
formatter_
->
format
(
msg
,
formatted
);
sink
::
formatter_
->
format
(
msg
,
formatted
);
ostream_
.
write
(
formatted
.
data
(),
formatted
.
size
(
));
ostream_
.
write
(
formatted
.
data
(),
static_cast
<
std
::
streamsize
>
(
formatted
.
size
()
));
if
(
force_flush_
)
if
(
force_flush_
)
ostream_
.
flush
();
ostream_
.
flush
();
}
}
...
...
tests/Makefile
View file @
a58d7594
CXX
?=
g++
CXX
?=
g++
CXXFLAGS
=
-Wall
-pedantic
-std
=
c++11
-pthread
-O3
-I
../include
-fmax-errors
=
1
CXXFLAGS
=
-Wall
-pedantic
-std
=
c++11
-pthread
-
Wconversion
-
O3
-I
../include
-fmax-errors
=
1
LDPFALGS
=
-pthread
LDPFALGS
=
-pthread
CPP_FILES
:=
$(
wildcard
*
.cpp
)
CPP_FILES
:=
$(
wildcard
*
.cpp
)
...
...
tests/registry.cpp
View file @
a58d7594
...
@@ -9,7 +9,7 @@ TEST_CASE("register_drop", "[registry]")
...
@@ -9,7 +9,7 @@ TEST_CASE("register_drop", "[registry]")
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
);
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
);
REQUIRE
(
spdlog
::
get
(
tested_logger_name
)
!=
nullptr
);
REQUIRE
(
spdlog
::
get
(
tested_logger_name
)
!=
nullptr
);
// Throw if registring existing name
// Throw if registring existing name
REQUIRE_THROWS_AS
(
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
),
const
spdlog
::
spdlog_ex
&
);
REQUIRE_THROWS_AS
(
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
),
const
spdlog
::
spdlog_ex
&
);
}
}
TEST_CASE
(
"explicit register"
TEST_CASE
(
"explicit register"
...
@@ -20,7 +20,7 @@ TEST_CASE("explicit register"
...
@@ -20,7 +20,7 @@ TEST_CASE("explicit register"
spdlog
::
register_logger
(
logger
);
spdlog
::
register_logger
(
logger
);
REQUIRE
(
spdlog
::
get
(
tested_logger_name
)
!=
nullptr
);
REQUIRE
(
spdlog
::
get
(
tested_logger_name
)
!=
nullptr
);
// Throw if registring existing name
// Throw if registring existing name
REQUIRE_THROWS_AS
(
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
),
const
spdlog
::
spdlog_ex
&
);
REQUIRE_THROWS_AS
(
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
tested_logger_name
),
const
spdlog
::
spdlog_ex
&
);
}
}
TEST_CASE
(
"apply_all"
TEST_CASE
(
"apply_all"
...
...
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