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
eea9d613
Commit
eea9d613
authored
Jun 03, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved default sync factory to seperate file to avoid cyclic includes
parent
c35f33e6
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
59 additions
and
35 deletions
+59
-35
common.h
include/spdlog/common.h
+2
-0
registry.h
include/spdlog/details/registry.h
+2
-2
synchronous_factory.h
include/spdlog/details/synchronous_factory.h
+23
-0
android_sink.h
include/spdlog/sinks/android_sink.h
+3
-2
ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+1
-0
basic_file_sink.h
include/spdlog/sinks/basic_file_sink.h
+3
-2
daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+3
-2
null_sink.h
include/spdlog/sinks/null_sink.h
+3
-2
rotating_file_sink.h
include/spdlog/sinks/rotating_file_sink.h
+3
-2
stdout_color_sinks.h
include/spdlog/sinks/stdout_color_sinks.h
+7
-4
stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+5
-4
systemd_sink.h
include/spdlog/sinks/systemd_sink.h
+3
-2
spdlog.h
include/spdlog/spdlog.h
+1
-13
No files found.
include/spdlog/common.h
View file @
eea9d613
...
...
@@ -222,6 +222,8 @@ std::unique_ptr<T> make_unique(Args &&... args)
}
#endif
}
// namespace details
}
// namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
...
...
include/spdlog/details/registry.h
View file @
eea9d613
...
...
@@ -3,8 +3,8 @@
#pragma once
// Loggers registy of unique name->logger pointer
// An attempt to create a logger with an already existing name will
be ignored
// Loggers regist
r
y of unique name->logger pointer
// An attempt to create a logger with an already existing name will
result with spdlog_ex exception.
// If user requests a non existing logger, nullptr will be returned
// This class is thread safe
...
...
include/spdlog/details/synchronous_factory.h
0 → 100644
View file @
eea9d613
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "registry.h"
namespace
spdlog
{
// Default logger factory- creates synchronous loggers
class
logger
;
struct
synchronous_factory
{
template
<
typename
Sink
,
typename
...
SinkArgs
>
static
std
::
shared_ptr
<
spdlog
::
logger
>
create
(
std
::
string
logger_name
,
SinkArgs
&&
...
args
)
{
auto
sink
=
std
::
make_shared
<
Sink
>
(
std
::
forward
<
SinkArgs
>
(
args
)...);
auto
new_logger
=
std
::
make_shared
<
spdlog
::
logger
>
(
std
::
move
(
logger_name
),
std
::
move
(
sink
));
details
::
registry
::
instance
().
initialize_logger
(
new_logger
);
return
new_logger
;
}
};
}
\ No newline at end of file
include/spdlog/sinks/android_sink.h
View file @
eea9d613
...
...
@@ -7,6 +7,7 @@
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/os.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/synchronous_factory.h"
#include <android/log.h>
#include <chrono>
...
...
@@ -99,13 +100,13 @@ using android_sink_st = android_sink<details::null_mutex>;
// Create and register android syslog logger
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
android_logger_mt
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
tag
=
"spdlog"
)
{
return
Factory
::
template
create
<
sinks
::
android_sink_mt
>
(
logger_name
,
tag
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
android_logger_st
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
tag
=
"spdlog"
)
{
return
Factory
::
template
create
<
sinks
::
android_sink_st
>
(
logger_name
,
tag
);
...
...
include/spdlog/sinks/ansicolor_sink.h
View file @
eea9d613
...
...
@@ -77,6 +77,7 @@ private:
void
print_range_
(
const
fmt
::
memory_buffer
&
formatted
,
size_t
start
,
size_t
end
);
};
using
ansicolor_stdout_sink_mt
=
ansicolor_sink
<
details
::
console_stdout
,
details
::
console_mutex
>
;
using
ansicolor_stdout_sink_st
=
ansicolor_sink
<
details
::
console_stdout
,
details
::
console_nullmutex
>
;
...
...
include/spdlog/sinks/basic_file_sink.h
View file @
eea9d613
...
...
@@ -6,6 +6,7 @@
#include "spdlog/details/file_helper.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/synchronous_factory.h"
#include <mutex>
#include <string>
...
...
@@ -38,13 +39,13 @@ using basic_file_sink_st = basic_file_sink<details::null_mutex>;
//
// factory functions
//
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
)
{
return
Factory
::
template
create
<
sinks
::
basic_file_sink_mt
>
(
logger_name
,
filename
,
truncate
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
)
{
return
Factory
::
template
create
<
sinks
::
basic_file_sink_st
>
(
logger_name
,
filename
,
truncate
);
...
...
include/spdlog/sinks/daily_file_sink.h
View file @
eea9d613
...
...
@@ -8,6 +8,7 @@
#include "spdlog/fmt/fmt.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/os.h"
#include "spdlog/details/synchronous_factory.h"
#include <chrono>
#include <cstdio>
...
...
@@ -120,14 +121,14 @@ using daily_file_sink_st = daily_file_sink<details::null_mutex>;
//
// factory functions
//
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
)
{
return
Factory
::
template
create
<
sinks
::
daily_file_sink_mt
>
(
logger_name
,
filename
,
hour
,
minute
,
truncate
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
)
{
...
...
include/spdlog/sinks/null_sink.h
View file @
eea9d613
...
...
@@ -5,6 +5,7 @@
#include "spdlog/details/null_mutex.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/synchronous_factory.h"
#include <mutex>
...
...
@@ -24,7 +25,7 @@ using null_sink_st = null_sink<details::null_mutex>;
}
// namespace sinks
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
null_logger_mt
(
const
std
::
string
&
logger_name
)
{
auto
null_logger
=
Factory
::
template
create
<
sinks
::
null_sink_mt
>
(
logger_name
);
...
...
@@ -32,7 +33,7 @@ inline std::shared_ptr<logger> null_logger_mt(const std::string &logger_name)
return
null_logger
;
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
null_logger_st
(
const
std
::
string
&
logger_name
)
{
auto
null_logger
=
Factory
::
template
create
<
sinks
::
null_sink_st
>
(
logger_name
);
...
...
include/spdlog/sinks/rotating_file_sink.h
View file @
eea9d613
...
...
@@ -5,6 +5,7 @@
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/file_helper.h"
#include "spdlog/details/synchronous_factory.h"
#include <chrono>
#include <mutex>
...
...
@@ -56,14 +57,14 @@ using rotating_file_sink_st = rotating_file_sink<details::null_mutex>;
// factory functions
//
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
rotate_on_open
=
false
)
{
return
Factory
::
template
create
<
sinks
::
rotating_file_sink_mt
>
(
logger_name
,
filename
,
max_file_size
,
max_files
,
rotate_on_open
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
rotate_on_open
=
false
)
{
...
...
include/spdlog/sinks/stdout_color_sinks.h
View file @
eea9d613
...
...
@@ -9,6 +9,8 @@
#include "spdlog/sinks/ansicolor_sink.h"
#endif
#include "spdlog/details/synchronous_factory.h"
namespace
spdlog
{
namespace
sinks
{
#ifdef _WIN32
...
...
@@ -24,16 +26,17 @@ using stderr_color_sink_st = ansicolor_stderr_sink_st;
#endif
}
// namespace sinks
template
<
typename
Factory
=
default_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
std
::
shared_ptr
<
logger
>
stdout_color_mt
(
const
std
::
string
&
logger_name
,
color_mode
mode
=
color_mode
::
automatic
);
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
std
::
shared_ptr
<
logger
>
stdout_color_st
(
const
std
::
string
&
logger_name
,
color_mode
mode
=
color_mode
::
automatic
);
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
std
::
shared_ptr
<
logger
>
stderr_color_mt
(
const
std
::
string
&
logger_name
,
color_mode
mode
=
color_mode
::
automatic
);
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
std
::
shared_ptr
<
logger
>
stderr_color_st
(
const
std
::
string
&
logger_name
,
color_mode
mode
=
color_mode
::
automatic
);
}
// namespace spdlog
...
...
include/spdlog/sinks/stdout_sinks.h
View file @
eea9d613
...
...
@@ -6,6 +6,7 @@
#include "spdlog/details/console_globals.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/pattern_formatter.h"
#include "spdlog/details/synchronous_factory.h"
#include <cstdio>
#include <memory>
...
...
@@ -70,25 +71,25 @@ using stderr_sink_st = stdout_sink<details::console_stderr, details::console_nul
}
// namespace sinks
// factory methods
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
stdout_logger_mt
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
stdout_sink_mt
>
(
logger_name
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
stdout_logger_st
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
stdout_sink_st
>
(
logger_name
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
stderr_logger_mt
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
stderr_sink_mt
>
(
logger_name
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
stderr_logger_st
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
stderr_sink_st
>
(
logger_name
);
...
...
include/spdlog/sinks/systemd_sink.h
View file @
eea9d613
...
...
@@ -4,6 +4,7 @@
#pragma once
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/synchronous_factory.h"
#include <array>
#include <string>
...
...
@@ -65,13 +66,13 @@ using systemd_sink_st = systemd_sink<details::null_mutex>;
}
// namespace sinks
// Create and register a syslog logger
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
systemd_logger_mt
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
systemd_sink_mt
>
(
logger_name
);
}
template
<
typename
Factory
=
default
_factory
>
template
<
typename
Factory
=
spdlog
::
synchronous
_factory
>
inline
std
::
shared_ptr
<
logger
>
systemd_logger_st
(
const
std
::
string
&
logger_name
)
{
return
Factory
::
template
create
<
sinks
::
systemd_sink_st
>
(
logger_name
);
...
...
include/spdlog/spdlog.h
View file @
eea9d613
...
...
@@ -13,6 +13,7 @@
#include "spdlog/details/registry.h"
#include "spdlog/logger.h"
#include "spdlog/version.h"
#include "spdlog/details/synchronous_factory.h"
#include <chrono>
#include <functional>
...
...
@@ -21,19 +22,6 @@
namespace
spdlog
{
// Default logger factory- creates synchronous loggers
struct
synchronous_factory
{
template
<
typename
Sink
,
typename
...
SinkArgs
>
static
std
::
shared_ptr
<
spdlog
::
logger
>
create
(
std
::
string
logger_name
,
SinkArgs
&&
...
args
)
{
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
().
initialize_logger
(
new_logger
);
return
new_logger
;
}
};
using
default_factory
=
synchronous_factory
;
// Create and register a logger with a templated sink type
...
...
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