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
9cad840a
Commit
9cad840a
authored
May 09, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "vector / mutex"
This reverts commit
a74e280b
. Conflicts: include/spdlog/tweakme.h
parent
fa038547
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
56 deletions
+1
-56
registry.h
include/spdlog/details/registry.h
+1
-43
tweakme.h
include/spdlog/tweakme.h
+0
-13
No files found.
include/spdlog/details/registry.h
View file @
9cad840a
...
...
@@ -54,19 +54,9 @@ public:
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
logger_name
)
{
#ifndef SPDLOG_NO_REGISTRY_MUTEX
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
#endif
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
for
(
auto
&
logger
:
_loggers
)
{
if
(
logger_name
==
logger
->
name
())
return
logger
;
}
return
nullptr
;
#else
auto
found
=
_loggers
.
find
(
logger_name
);
return
found
==
_loggers
.
end
()
?
nullptr
:
found
->
second
;
#endif
}
template
<
class
It
>
...
...
@@ -94,17 +84,7 @@ public:
void
drop
(
const
std
::
string
&
logger_name
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
for
(
auto
it
=
_loggers
.
begin
();
it
!=
_loggers
.
end
();)
{
if
(
logger_name
==
(
*
it
)
->
name
())
{
it
=
_loggers
.
erase
(
it
);
}
else
{
++
it
;
}
}
#else
_loggers
.
erase
(
logger_name
);
#endif
}
void
drop_all
()
...
...
@@ -128,11 +108,7 @@ public:
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
_formatter
=
f
;
for
(
auto
&
l
:
_loggers
)
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
l
->
set_formatter
(
_formatter
);
#else
l
.
second
->
set_formatter
(
_formatter
);
#endif
}
void
set_pattern
(
const
std
::
string
&
pattern
)
...
...
@@ -140,22 +116,14 @@ public:
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
pattern
);
for
(
auto
&
l
:
_loggers
)
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
l
->
set_formatter
(
_formatter
);
#else
l
.
second
->
set_formatter
(
_formatter
);
#endif
}
void
set_level
(
level
::
level_enum
log_level
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
for
(
auto
&
l
:
_loggers
)
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
l
->
set_level
(
log_level
);
#else
l
.
second
->
set_level
(
log_level
);
#endif
_level
=
log_level
;
}
...
...
@@ -184,25 +152,15 @@ private:
void
register_logger_impl
(
std
::
shared_ptr
<
logger
>
logger
)
{
auto
logger_name
=
logger
->
name
();
if
(
get
(
logger_name
)
!=
nullptr
)
if
(
_loggers
.
find
(
logger_name
)
!=
std
::
end
(
_loggers
)
)
throw
spdlog_ex
(
"logger with name "
+
logger_name
+
" already exists"
);
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
_loggers
.
push_back
(
logger
);
#else
_loggers
[
logger
->
name
()]
=
logger
;
#endif
}
registry
()
=
default
;
registry
(
const
registry
&
)
=
delete
;
registry
&
operator
=
(
const
registry
&
)
=
delete
;
std
::
mutex
_mutex
;
#ifdef SPDLOG_VECTOR_BASED_REGISTRY
std
::
vector
<
std
::
shared_ptr
<
logger
>>
_loggers
;
#else
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
logger
>>
_loggers
;
#endif
formatter_ptr
_formatter
;
level
::
level_enum
_level
=
level
::
info
;
bool
_async_mode
=
false
;
...
...
include/spdlog/tweakme.h
View file @
9cad840a
...
...
@@ -65,16 +65,3 @@
// #define SPDLOG_TRACE_ON
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to avoid locking in the registry operations (spdlog::get() spdlog::drop() spdlog::register())
// Use only if your code is single threaded or never modifes concurrently the registry
// #define SPDLOG_NO_REGISTRY_MUTEX
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable vector based registry instead of the default unordered_map
// spdlog::get(..) operations will be faster on small registry sizes (upto ~10-20 loggers)
// #define SPDLOG_VECTOR_BASED_REGISTRY
///////////////////////////////////////////////////////////////////////////////
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