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
408a1620
Commit
408a1620
authored
Aug 27, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed logger::clone() from API
parent
7d644449
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
76 deletions
+19
-76
example/example.cpp
example/example.cpp
+0
-9
include/spdlog/async_logger-inl.h
include/spdlog/async_logger-inl.h
+0
-6
include/spdlog/async_logger.h
include/spdlog/async_logger.h
+0
-1
include/spdlog/logger-inl.h
include/spdlog/logger-inl.h
+0
-9
include/spdlog/logger.h
include/spdlog/logger.h
+18
-8
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+1
-2
tests/test_misc.cpp
tests/test_misc.cpp
+0
-41
No files found.
example/example.cpp
View file @
408a1620
...
...
@@ -47,7 +47,6 @@ int main(int, char *[])
basic_example
();
rotating_example
();
daily_example
();
clone_example
();
async_example
();
binary_example
();
multi_sink_example
();
...
...
@@ -106,14 +105,6 @@ void daily_example()
auto
daily_logger
=
spdlog
::
daily_logger_mt
(
"daily_logger"
,
"logs/daily.txt"
,
2
,
30
);
}
// Clone a logger and give it new name.
// Useful for creating component/subsystem loggers from some "root" logger.
void
clone_example
()
{
auto
network_logger
=
spdlog
::
default_logger
()
->
clone
(
"network"
);
network_logger
->
info
(
"Logging network stuff.."
);
}
#include "spdlog/async.h"
void
async_example
()
{
...
...
include/spdlog/async_logger-inl.h
View file @
408a1620
...
...
@@ -78,9 +78,3 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_()
spdlog
::
logger
::
flush_
();
}
SPDLOG_INLINE
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
async_logger
::
clone
(
std
::
string
new_name
)
{
auto
cloned
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
*
this
);
cloned
->
name_
=
std
::
move
(
new_name
);
return
cloned
;
}
include/spdlog/async_logger.h
View file @
408a1620
...
...
@@ -49,7 +49,6 @@ public:
async_logger
(
std
::
string
logger_name
,
sink_ptr
single_sink
,
std
::
weak_ptr
<
details
::
thread_pool
>
tp
,
async_overflow_policy
overflow_policy
=
async_overflow_policy
::
block
);
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
new_name
)
override
;
protected:
void
sink_it_
(
const
details
::
log_msg
&
msg
)
override
;
...
...
include/spdlog/logger-inl.h
View file @
408a1620
...
...
@@ -64,7 +64,6 @@ SPDLOG_INLINE void swap(logger &a, logger &b)
a
.
swap
(
b
);
}
SPDLOG_INLINE
bool
logger
::
should_log
(
level
::
level_enum
msg_level
)
const
{
return
msg_level
>=
level_
.
load
(
std
::
memory_order_relaxed
);
...
...
@@ -159,14 +158,6 @@ SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
custom_err_handler_
=
handler
;
}
// create new logger with same sinks and configuration.
SPDLOG_INLINE
std
::
shared_ptr
<
logger
>
logger
::
clone
(
std
::
string
logger_name
)
{
auto
cloned
=
std
::
make_shared
<
logger
>
(
*
this
);
cloned
->
name_
=
std
::
move
(
logger_name
);
return
cloned
;
}
// protected methods
SPDLOG_INLINE
void
logger
::
sink_it_
(
const
details
::
log_msg
&
msg
)
{
...
...
include/spdlog/logger.h
View file @
408a1620
...
...
@@ -81,7 +81,7 @@ public:
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
string_view_t
fmt
,
const
Args
&
...
args
)
{
auto
level_enabled
=
should_log
(
lvl
);
if
(
!
level_enabled
&&
!
tracer_
)
if
(
!
level_enabled
&&
!
tracer_
)
{
return
;
}
...
...
@@ -90,8 +90,14 @@ public:
fmt
::
memory_buffer
buf
;
fmt
::
format_to
(
buf
,
fmt
,
args
...);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
if
(
level_enabled
)
sink_it_
(
log_msg
);
if
(
tracer_
)
backtrace_add_
(
log_msg
);
if
(
level_enabled
)
{
sink_it_
(
log_msg
);
}
if
(
tracer_
)
{
backtrace_add_
(
log_msg
);
}
}
SPDLOG_LOGGER_CATCH
()
}
...
...
@@ -149,15 +155,21 @@ public:
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
auto
level_enabled
=
should_log
(
lvl
);
if
(
!
level_enabled
&&
!
tracer_
)
if
(
!
level_enabled
&&
!
tracer_
)
{
return
;
}
SPDLOG_TRY
{
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
msg
);
if
(
level_enabled
)
sink_it_
(
log_msg
);
if
(
tracer_
)
backtrace_add_
(
log_msg
);
if
(
level_enabled
)
{
sink_it_
(
log_msg
);
}
if
(
tracer_
)
{
backtrace_add_
(
log_msg
);
}
}
SPDLOG_LOGGER_CATCH
()
}
...
...
@@ -340,8 +352,6 @@ public:
// error handler
void
set_error_handler
(
err_handler
);
// create new logger with same sinks and configuration.
virtual
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
logger_name
);
protected:
std
::
string
name_
;
...
...
include/spdlog/spdlog.h
View file @
408a1620
...
...
@@ -285,8 +285,7 @@ inline void critical(wstring_view_t fmt, const Args &... args)
// SPDLOG_LEVEL_OFF
//
#define SPDLOG_LOGGER_CALL(logger, level, ...)\
logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \
#define SPDLOG_LOGGER_CALL(logger, level, ...) logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__);
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
#define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
...
...
tests/test_misc.cpp
View file @
408a1620
...
...
@@ -92,47 +92,6 @@ TEST_CASE("periodic flush", "[periodic_flush]")
spdlog
::
drop_all
();
}
TEST_CASE
(
"clone-logger"
,
"[clone]"
)
{
using
namespace
spdlog
;
auto
logger
=
spdlog
::
create
<
sinks
::
test_sink_mt
>
(
"orig"
);
auto
cloned
=
logger
->
clone
(
"clone"
);
REQUIRE
(
cloned
->
name
()
==
"clone"
);
REQUIRE
(
logger
->
sinks
()
==
cloned
->
sinks
());
REQUIRE
(
logger
->
level
()
==
cloned
->
level
());
REQUIRE
(
logger
->
flush_level
()
==
cloned
->
flush_level
());
logger
->
info
(
"Some message 1"
);
cloned
->
info
(
"Some message 2"
);
auto
test_sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
cloned
->
sinks
()[
0
]);
spdlog
::
drop_all
();
}
TEST_CASE
(
"clone async"
,
"[clone]"
)
{
using
namespace
spdlog
;
auto
logger
=
spdlog
::
create_async
<
sinks
::
test_sink_mt
>
(
"orig"
);
auto
cloned
=
logger
->
clone
(
"clone"
);
REQUIRE
(
cloned
->
name
()
==
"clone"
);
REQUIRE
(
logger
->
sinks
()
==
cloned
->
sinks
());
REQUIRE
(
logger
->
level
()
==
cloned
->
level
());
REQUIRE
(
logger
->
flush_level
()
==
cloned
->
flush_level
());
logger
->
info
(
"Some message 1"
);
cloned
->
info
(
"Some message 2"
);
spdlog
::
details
::
os
::
sleep_for_millis
(
10
);
auto
test_sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
cloned
->
sinks
()[
0
]);
spdlog
::
drop_all
();
}
#include "spdlog/fmt/bin_to_hex.h"
TEST_CASE
(
"to_hex"
,
"[to_hex]"
)
...
...
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