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
256c64d7
Commit
256c64d7
authored
Apr 11, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed registry functions
parent
623f59ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
registry.h
include/spdlog/details/registry.h
+17
-9
spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+2
-2
spdlog.h
include/spdlog/spdlog.h
+1
-1
No files found.
include/spdlog/details/registry.h
View file @
256c64d7
...
...
@@ -45,9 +45,10 @@ class registry
{
public
:
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
,
const
std
::
string
&
logger_name
)
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
_loggers
[
logger_name
]
=
logger
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
register_logger_impl
(
logger
);
}
...
...
@@ -61,12 +62,12 @@ public:
template
<
class
It
>
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
//If already exists, just return it
auto
found
=
_loggers
.
find
(
logger_name
);
if
(
found
!=
_loggers
.
end
())
return
found
->
second
;
std
::
shared_ptr
<
logger
>
new_logger
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
if
(
_async_mode
)
new_logger
=
std
::
make_shared
<
async_logger
>
(
logger_name
,
sinks_begin
,
sinks_end
,
_async_q_size
,
_overflow_policy
,
_worker_warmup_cb
);
else
...
...
@@ -74,9 +75,9 @@ public:
if
(
_formatter
)
new_logger
->
set_formatter
(
_formatter
);
new_logger
->
set_level
(
_level
);
register_logger
(
new_logger
,
logger_name
);
new_logger
->
set_level
(
_level
);
register_logger_impl
(
new_logger
);
return
new_logger
;
}
...
...
@@ -148,6 +149,13 @@ public:
}
private
:
void
register_logger_impl
(
std
::
shared_ptr
<
logger
>
logger
)
{
auto
logger_name
=
logger
->
name
();
if
(
_loggers
.
find
(
logger_name
)
!=
std
::
end
(
_loggers
))
throw
spdlog_ex
(
"logger with name "
+
logger_name
+
" already exists"
);
_loggers
[
logger
->
name
()]
=
logger
;
}
registry
()
=
default
;
registry
(
const
registry
&
)
=
delete
;
registry
&
operator
=
(
const
registry
&
)
=
delete
;
...
...
include/spdlog/details/spdlog_impl.h
View file @
256c64d7
...
...
@@ -32,9 +32,9 @@
#include "../sinks/stdout_sinks.h"
#include "../sinks/syslog_sink.h"
inline
void
spdlog
::
register_logger
(
std
::
shared_ptr
<
logger
>
logger
,
const
std
::
string
&
logger_name
)
inline
void
spdlog
::
register_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
return
details
::
registry
::
instance
().
register_logger
(
logger
,
logger_name
);
return
details
::
registry
::
instance
().
register_logger
(
logger
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
get
(
const
std
::
string
&
name
)
...
...
include/spdlog/spdlog.h
View file @
256c64d7
...
...
@@ -116,7 +116,7 @@ std::shared_ptr<spdlog::logger> create(const std::string& logger_name, const Arg
// Register the given logger with the given name
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
,
const
std
::
string
&
logger_name
);
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
);
// Drop the reference to the given logger
void
drop
(
const
std
::
string
&
name
);
...
...
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