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
c16eb80d
Commit
c16eb80d
authored
Apr 08, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed multiple clang-tidy warnings
parent
0c56f98a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
15 deletions
+33
-15
include/spdlog/cfg/argv.h
include/spdlog/cfg/argv.h
+7
-2
include/spdlog/sinks/ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+4
-0
include/spdlog/sinks/base_sink.h
include/spdlog/sinks/base_sink.h
+6
-0
include/spdlog/sinks/stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+4
-0
tests/test_cfg.cpp
tests/test_cfg.cpp
+7
-7
tests/test_mpmc_q.cpp
tests/test_mpmc_q.cpp
+5
-6
No files found.
include/spdlog/cfg/argv.h
View file @
c16eb80d
...
...
@@ -21,10 +21,10 @@ namespace spdlog {
namespace
cfg
{
// search for SPDLOG_LEVEL= in the args and use it to init the levels
void
load_argv_levels
(
int
arg
s
,
char
**
argv
)
void
load_argv_levels
(
int
arg
c
,
const
char
**
argv
)
{
const
std
::
string
spdlog_level_prefix
=
"SPDLOG_LEVEL="
;
for
(
int
i
=
1
;
i
<
arg
s
;
i
++
)
for
(
int
i
=
1
;
i
<
arg
c
;
i
++
)
{
std
::
string
arg
=
argv
[
i
];
if
(
arg
.
find
(
spdlog_level_prefix
)
==
0
)
...
...
@@ -36,5 +36,10 @@ void load_argv_levels(int args, char **argv)
}
}
void
load_argv_levels
(
int
argc
,
char
**
argv
)
{
load_argv_levels
(
argc
,
const_cast
<
const
char
**>
(
argv
));
}
}
// namespace cfg
}
// namespace spdlog
include/spdlog/sinks/ansicolor_sink.h
View file @
c16eb80d
...
...
@@ -30,7 +30,11 @@ public:
~
ansicolor_sink
()
override
=
default
;
ansicolor_sink
(
const
ansicolor_sink
&
other
)
=
delete
;
ansicolor_sink
(
ansicolor_sink
&&
other
)
=
delete
;
ansicolor_sink
&
operator
=
(
const
ansicolor_sink
&
other
)
=
delete
;
ansicolor_sink
&
operator
=
(
ansicolor_sink
&&
other
)
=
delete
;
void
set_color
(
level
::
level_enum
color_level
,
string_view_t
color
);
void
set_color_mode
(
color_mode
mode
);
bool
should_color
();
...
...
include/spdlog/sinks/base_sink.h
View file @
c16eb80d
...
...
@@ -21,8 +21,14 @@ class base_sink : public sink
public:
base_sink
();
explicit
base_sink
(
std
::
unique_ptr
<
spdlog
::
formatter
>
formatter
);
~
base_sink
()
override
=
default
;
base_sink
(
const
base_sink
&
)
=
delete
;
base_sink
(
base_sink
&&
)
=
delete
;
base_sink
&
operator
=
(
const
base_sink
&
)
=
delete
;
base_sink
&
operator
=
(
base_sink
&&
)
=
delete
;
void
log
(
const
details
::
log_msg
&
msg
)
final
;
void
flush
()
final
;
void
set_pattern
(
const
std
::
string
&
pattern
)
final
;
...
...
include/spdlog/sinks/stdout_sinks.h
View file @
c16eb80d
...
...
@@ -19,8 +19,12 @@ public:
using
mutex_t
=
typename
ConsoleMutex
::
mutex_t
;
explicit
stdout_sink_base
(
FILE
*
file
);
~
stdout_sink_base
()
override
=
default
;
stdout_sink_base
(
const
stdout_sink_base
&
other
)
=
delete
;
stdout_sink_base
(
stdout_sink_base
&&
other
)
=
delete
;
stdout_sink_base
&
operator
=
(
const
stdout_sink_base
&
other
)
=
delete
;
stdout_sink_base
&
operator
=
(
stdout_sink_base
&&
other
)
=
delete
;
void
log
(
const
details
::
log_msg
&
msg
)
override
;
void
flush
()
override
;
...
...
tests/test_cfg.cpp
View file @
c16eb80d
...
...
@@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]")
{
spdlog
::
drop
(
"l1"
);
const
char
*
argv
[]
=
{
"ignore"
,
"SPDLOG_LEVEL=l1=warn"
};
load_argv_levels
(
2
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
2
,
argv
);
auto
l1
=
spdlog
::
create
<
spdlog
::
sinks
::
test_sink_st
>
(
"l1"
);
REQUIRE
(
l1
->
level
()
==
spdlog
::
level
::
warn
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
info
);
...
...
@@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]")
{
spdlog
::
drop
(
"l1"
);
const
char
*
argv
[]
=
{
"ignore"
,
"SPDLOG_LEVEL=l1=warn,trace"
};
load_argv_levels
(
2
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
2
,
argv
);
auto
l1
=
spdlog
::
create
<
test_sink_st
>
(
"l1"
);
REQUIRE
(
l1
->
level
()
==
spdlog
::
level
::
warn
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
trace
);
...
...
@@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]")
{
spdlog
::
drop
(
"l1"
);
const
char
*
argv
[]
=
{
"ignore"
,
"SPDLOG_LEVEL="
};
load_argv_levels
(
2
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
2
,
argv
);
auto
l1
=
spdlog
::
create
<
test_sink_st
>
(
"l1"
);
REQUIRE
(
l1
->
level
()
==
spdlog
::
level
::
info
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
info
);
...
...
@@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]")
{
spdlog
::
drop
(
"l1"
);
const
char
*
argv
[]
=
{
"ignore"
,
"SPDLOG_LEVEL=junk"
};
load_argv_levels
(
2
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
2
,
argv
);
auto
l1
=
spdlog
::
create
<
test_sink_st
>
(
"l1"
);
REQUIRE
(
l1
->
level
()
==
spdlog
::
level
::
info
);
}
...
...
@@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]")
{
spdlog
::
drop
(
"l1"
);
const
char
*
argv
[]
=
{
"ignore"
,
"ignore"
,
"SPDLOG_LEVEL=l1=warn,trace"
};
load_argv_levels
(
3
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
3
,
argv
);
auto
l1
=
spdlog
::
create
<
test_sink_st
>
(
"l1"
);
REQUIRE
(
l1
->
level
()
==
spdlog
::
level
::
warn
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
trace
);
...
...
@@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]")
{
spdlog
::
set_level
(
spdlog
::
level
::
err
);
const
char
*
argv
[]
=
{
""
};
load_argv_levels
(
1
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
1
,
argv
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
err
);
spdlog
::
set_level
(
spdlog
::
level
::
info
);
}
...
...
@@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]")
{
spdlog
::
set_level
(
spdlog
::
level
::
err
);
const
char
*
argv
[]
=
{
""
};
load_argv_levels
(
0
,
const_cast
<
char
**>
(
argv
)
);
load_argv_levels
(
0
,
argv
);
REQUIRE
(
spdlog
::
default_logger
()
->
level
()
==
spdlog
::
level
::
err
);
spdlog
::
set_level
(
spdlog
::
level
::
info
);
}
tests/test_mpmc_q.cpp
View file @
c16eb80d
#include "includes.h"
using
namespace
std
::
chrono
;
using
std
::
chrono
::
milliseconds
;
using
test_clock
=
std
::
chrono
::
high_resolution_clock
;
...
...
@@ -13,7 +12,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]")
size_t
q_size
=
100
;
milliseconds
tolerance_wait
(
10
);
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
int
popped_item
;
int
popped_item
=
0
;
auto
start
=
test_clock
::
now
();
auto
rv
=
q
.
dequeue_for
(
popped_item
,
milliseconds
::
zero
());
...
...
@@ -32,7 +31,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
milliseconds
tolerance_wait
(
250
);
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
int
popped_item
;
int
popped_item
=
0
;
auto
start
=
test_clock
::
now
();
auto
rv
=
q
.
dequeue_for
(
popped_item
,
wait_ms
);
auto
delta_ms
=
millis_from
(
start
);
...
...
@@ -69,7 +68,7 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]")
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
q
.
enqueue_nowait
(
1
);
REQUIRE
(
q
.
overrun_counter
()
==
1
);
int
i
;
int
i
=
0
;
REQUIRE
(
q
.
dequeue_for
(
i
,
milliseconds
(
0
))
==
false
);
}
...
...
@@ -77,7 +76,7 @@ TEST_CASE("empty_queue", "[mpmc_blocking_q]")
{
size_t
q_size
=
10
;
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
int
i
;
int
i
=
0
;
REQUIRE
(
q
.
dequeue_for
(
i
,
milliseconds
(
10
))
==
false
);
}
...
...
@@ -87,7 +86,7 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]")
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
q_size
);
i
++
)
{
q
.
enqueue
(
std
::
move
(
i
));
q
.
enqueue
(
i
+
0
);
// i+0 to force rvalue and avoid tidy warnings on the same time
}
q
.
enqueue_nowait
(
123456
);
...
...
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