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
f95b189f
Commit
f95b189f
authored
Nov 04, 2018
by
Pablo Arias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a global option in tweakme.h that disabled global registration of
loggers. fixes #712
parent
1aace95c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
11 deletions
+17
-11
include/spdlog/async.h
include/spdlog/async.h
+4
-1
include/spdlog/details/registry.h
include/spdlog/details/registry.h
+1
-9
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+4
-1
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+8
-0
No files found.
include/spdlog/async.h
View file @
f95b189f
...
...
@@ -52,7 +52,10 @@ struct async_factory_impl
auto
sink
=
std
::
make_shared
<
Sink
>
(
std
::
forward
<
SinkArgs
>
(
args
)...);
auto
new_logger
=
std
::
make_shared
<
async_logger
>
(
std
::
move
(
logger_name
),
std
::
move
(
sink
),
std
::
move
(
tp
),
OverflowPolicy
);
registry_inst
.
register_and_init
(
new_logger
);
registry_inst
.
init_with_global_defaults
(
new_logger
);
#ifndef SPDLOG_DISABLE_GLOBAL_REGISTRATION
registry_inst
.
register_logger
(
new_logger
);
#endif
return
new_logger
;
}
};
...
...
include/spdlog/details/registry.h
View file @
f95b189f
...
...
@@ -47,13 +47,8 @@ public:
loggers_
[
logger_name
]
=
std
::
move
(
new_logger
);
}
void
register_and_init
(
std
::
shared_ptr
<
logger
>
new_logger
)
void
init_with_global_defaults
(
std
::
shared_ptr
<
logger
>
new_logger
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
logger_map_mutex_
);
auto
logger_name
=
new_logger
->
name
();
throw_if_exists_
(
logger_name
);
// set the global formatter pattern
new_logger
->
set_formatter
(
formatter_
->
clone
());
if
(
err_handler_
)
...
...
@@ -63,9 +58,6 @@ public:
new_logger
->
set_level
(
level_
);
new_logger
->
flush_on
(
flush_level_
);
// add to registry
loggers_
[
logger_name
]
=
std
::
move
(
new_logger
);
}
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
logger_name
)
...
...
include/spdlog/spdlog.h
View file @
f95b189f
...
...
@@ -29,7 +29,10 @@ struct synchronous_factory
{
auto
sink
=
std
::
make_shared
<
Sink
>
(
std
::
forward
<
SinkArgs
>
(
args
)...);
auto
new_logger
=
std
::
make_shared
<
logger
>
(
std
::
move
(
logger_name
),
std
::
move
(
sink
));
details
::
registry
::
instance
().
register_and_init
(
new_logger
);
details
::
registry
::
instance
().
init_with_global_defaults
(
new_logger
);
#ifndef SPDLOG_DISABLE_GLOBAL_REGISTRATION
details
::
registry
::
instance
().
register_logger
(
new_logger
);
#endif
return
new_logger
;
}
};
...
...
include/spdlog/tweakme.h
View file @
f95b189f
...
...
@@ -128,3 +128,11 @@
//
// #define SPDLOG_DISABLE_DEFAULT_LOGGER
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to disable global logger registration
// This is useful if you don't need loggers to be globally accessible and part of the global registry.
// This option will allow you to use the same name for different loggers.
//
// #define SPDLOG_DISABLE_GLOBAL_REGISTRATION
///////////////////////////////////////////////////////////////////////////////
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