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
5d7845c1
Commit
5d7845c1
authored
Aug 25, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "clone()" support to loggers
parent
91d8869f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
17 deletions
+21
-17
README.md
README.md
+12
-0
example/example.cpp
example/example.cpp
+1
-1
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+1
-5
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+2
-2
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+2
-4
include/spdlog/logger.h
include/spdlog/logger.h
+0
-1
tests/includes.h
tests/includes.h
+1
-1
tests/test_mpmc_q.cpp
tests/test_mpmc_q.cpp
+2
-3
No files found.
README.md
View file @
5d7845c1
...
...
@@ -161,6 +161,18 @@ void daily_example()
---
#### Periodic flush
```
c++
// clone a logger and give it new name.
// Useful for creating subsystem loggers from some "root" logger
void
clone_example
()
{
auto
network_logger
=
spdlog
::
get
(
"console"
)
->
clone
(
"network"
);
network_logger
->
info
(
"Logging network stuff.."
);
}
```
---
#### Cloning loggers for
```
c++
// periodically flush all *registered* loggers every 3 seconds:
// warning: only use if all your loggers are thread safe!
spdlog
::
flush_every
(
std
::
chrono
::
seconds
(
3
));
...
...
example/example.cpp
View file @
5d7845c1
...
...
@@ -59,7 +59,7 @@ int main(int, char *[])
// release any threads created by spdlog, and drop all loggers in the registry.
spdlog
::
shutdown
();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
catch
(
const
spdlog
::
spdlog_ex
&
ex
)
{
std
::
cout
<<
"Log init failed: "
<<
ex
.
what
()
<<
std
::
endl
;
...
...
include/spdlog/details/async_logger_impl.h
View file @
5d7845c1
...
...
@@ -99,13 +99,9 @@ inline void spdlog::async_logger::backend_flush_()
SPDLOG_CATCH_AND_HANDLE
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
async_logger
::
clone
(
std
::
string
new_name
)
{
auto
cloned
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
std
::
move
(
new_name
),
sinks_
.
begin
(),
sinks_
.
end
(),
thread_pool_
,
overflow_policy_
);
auto
cloned
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
std
::
move
(
new_name
),
sinks_
.
begin
(),
sinks_
.
end
(),
thread_pool_
,
overflow_policy_
);
cloned
->
set_level
(
this
->
level
());
cloned
->
flush_on
(
this
->
flush_level
());
...
...
include/spdlog/details/fmt_helper.h
View file @
5d7845c1
...
...
@@ -22,8 +22,8 @@ inline void append_str(const std::string &str, fmt::basic_memory_buffer<char, Bu
template
<
size_t
Buffer_Size
>
inline
void
append_c_str
(
const
char
*
c_str
,
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size
>
&
dest
)
{
auto
len
=
std
::
char_traits
<
char
>::
length
(
c_str
);
dest
.
append
(
c_str
,
c_str
+
len
);
auto
len
=
std
::
char_traits
<
char
>::
length
(
c_str
);
dest
.
append
(
c_str
,
c_str
+
len
);
}
template
<
size_t
Buffer_Size1
,
size_t
Buffer_Size2
>
...
...
include/spdlog/details/logger_impl.h
View file @
5d7845c1
...
...
@@ -10,7 +10,6 @@
#include <memory>
#include <string>
// create logger with given name, sinks and the default pattern formatter
// all other ctors will call this one
template
<
typename
It
>
...
...
@@ -79,8 +78,8 @@ inline void spdlog::logger::log(level::level_enum lvl, const char *msg)
}
try
{
details
::
log_msg
log_msg
(
&
name_
,
lvl
);
details
::
fmt_helper
::
append_c_str
(
msg
,
log_msg
.
raw
);
details
::
log_msg
log_msg
(
&
name_
,
lvl
);
details
::
fmt_helper
::
append_c_str
(
msg
,
log_msg
.
raw
);
sink_it_
(
log_msg
);
}
SPDLOG_CATCH_AND_HANDLE
...
...
@@ -276,7 +275,6 @@ inline spdlog::level::level_enum spdlog::logger::flush_level() const
return
static_cast
<
spdlog
::
level
::
level_enum
>
(
flush_level_
.
load
(
std
::
memory_order_relaxed
));
}
inline
bool
spdlog
::
logger
::
should_flush_
(
const
details
::
log_msg
&
msg
)
{
auto
flush_level
=
flush_level_
.
load
(
std
::
memory_order_relaxed
);
...
...
include/spdlog/logger.h
View file @
5d7845c1
...
...
@@ -115,7 +115,6 @@ public:
level
::
level_enum
level
()
const
;
const
std
::
string
&
name
()
const
;
// set formatting for the sinks in this logger.
// each sink will get a seperate instance of the formatter object.
void
set_formatter
(
std
::
unique_ptr
<
formatter
>
formatter
);
...
...
tests/includes.h
View file @
5d7845c1
...
...
@@ -6,8 +6,8 @@
#include <cstdio>
#include <exception>
#include <fstream>
#include <ostream>
#include <iostream>
#include <ostream>
#include <string>
#define SPDLOG_TRACE_ON
...
...
tests/test_mpmc_q.cpp
View file @
5d7845c1
...
...
@@ -2,12 +2,11 @@
using
namespace
std
::
chrono
;
using
std
::
chrono
::
milliseconds
;
using
test_clock
=
std
::
chrono
::
high_resolution_clock
;
using
test_clock
=
std
::
chrono
::
high_resolution_clock
;
static
milliseconds
millis_from
(
const
test_clock
::
time_point
&
tp0
)
{
return
std
::
chrono
::
duration_cast
<
milliseconds
>
(
test_clock
::
now
()
-
tp0
);
return
std
::
chrono
::
duration_cast
<
milliseconds
>
(
test_clock
::
now
()
-
tp0
);
}
TEST_CASE
(
"dequeue-empty-nowait"
,
"[mpmc_blocking_q]"
)
{
...
...
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