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
623f59ce
Commit
623f59ce
authored
Apr 11, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added register_logger to spdlog.h to register manually created loggers
parent
8b4b5d27
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
registry.h
include/spdlog/details/registry.h
+10
-1
spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+5
-0
spdlog.h
include/spdlog/spdlog.h
+8
-5
No files found.
include/spdlog/details/registry.h
View file @
623f59ce
...
...
@@ -44,6 +44,13 @@ namespace details
class
registry
{
public
:
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
,
const
std
::
string
&
logger_name
)
{
_loggers
[
logger_name
]
=
logger
;
}
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
logger_name
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
...
...
@@ -68,7 +75,8 @@ public:
if
(
_formatter
)
new_logger
->
set_formatter
(
_formatter
);
new_logger
->
set_level
(
_level
);
_loggers
[
logger_name
]
=
new_logger
;
register_logger
(
new_logger
,
logger_name
);
return
new_logger
;
}
...
...
@@ -93,6 +101,7 @@ public:
return
create
(
logger_name
,
{
sink
});
}
void
formatter
(
formatter_ptr
f
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
...
...
include/spdlog/details/spdlog_impl.h
View file @
623f59ce
...
...
@@ -32,6 +32,11 @@
#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
)
{
return
details
::
registry
::
instance
().
register_logger
(
logger
,
logger_name
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
get
(
const
std
::
string
&
name
)
{
return
details
::
registry
::
instance
().
get
(
name
);
...
...
include/spdlog/spdlog.h
View file @
623f59ce
...
...
@@ -74,7 +74,7 @@ void set_async_mode(size_t queue_size, const async_overflow_policy overflow_poli
void
set_sync_mode
();
//
// Create multi/single threaded rotating file logger
// Create
and register
multi/single threaded rotating file logger
//
std
::
shared_ptr
<
logger
>
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
=
false
);
std
::
shared_ptr
<
logger
>
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
=
false
);
...
...
@@ -87,7 +87,7 @@ std::shared_ptr<logger> daily_logger_st(const std::string& logger_name, const st
//
// Create stdout/stderr loggers
// Create
and register
stdout/stderr loggers
//
std
::
shared_ptr
<
logger
>
stdout_logger_mt
(
const
std
::
string
&
logger_name
);
std
::
shared_ptr
<
logger
>
stdout_logger_st
(
const
std
::
string
&
logger_name
);
...
...
@@ -96,25 +96,28 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name);
//
// Create a syslog logger
// Create a
nd register a
syslog logger
//
#ifdef __linux__
std
::
shared_ptr
<
logger
>
syslog_logger
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
ident
=
""
,
int
syslog_option
=
0
);
#endif
// Create a logger with multiple sinks
// Create a
nd register a
logger with multiple sinks
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
);
template
<
class
It
>
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
);
// Create a logger with templated sink type
// Create a
nd register a
logger with templated sink type
// Example: spdlog::create<daily_file_sink_st>("mylog", "dailylog_filename", "txt");
template
<
typename
Sink
,
typename
...
Args
>
std
::
shared_ptr
<
spdlog
::
logger
>
create
(
const
std
::
string
&
logger_name
,
const
Args
&
...);
// Register the given logger with the given name
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
,
const
std
::
string
&
logger_name
);
// 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