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
89afa909
Commit
89afa909
authored
Jan 15, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shortened enum policy name and moved into common.h
parent
cd2a484e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
25 deletions
+25
-25
include/spdlog/async_logger.h
include/spdlog/async_logger.h
+3
-3
include/spdlog/common.h
include/spdlog/common.h
+11
-0
include/spdlog/details/async_log_helper.h
include/spdlog/details/async_log_helper.h
+4
-4
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+3
-3
include/spdlog/details/registry.h
include/spdlog/details/registry.h
+2
-2
include/spdlog/details/spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+1
-1
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+1
-12
No files found.
include/spdlog/async_logger.h
View file @
89afa909
...
...
@@ -53,9 +53,9 @@ class async_logger :public logger
{
public:
template
<
class
It
>
async_logger
(
const
std
::
string
&
name
,
const
It
&
begin
,
const
It
&
end
,
size_t
queue_size
,
const
async_queue_overflow_policy
overflow_policy
=
async_queue
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
async_logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
,
size_t
queue_size
,
const
async_queue_overflow_policy
overflow_policy
=
async_queue
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
async_logger
(
const
std
::
string
&
logger_name
,
sink_ptr
single_sink
,
size_t
queue_size
,
const
async_queue_overflow_policy
overflow_policy
=
async_queue
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
async_logger
(
const
std
::
string
&
name
,
const
It
&
begin
,
const
It
&
end
,
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
=
async
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
async_logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
,
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
=
async
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
async_logger
(
const
std
::
string
&
logger_name
,
sink_ptr
single_sink
,
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
=
async
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
protected:
...
...
include/spdlog/common.h
View file @
89afa909
...
...
@@ -75,6 +75,17 @@ inline const char* to_str(spdlog::level::level_enum l)
}
}
//level
//
// Async mode - off by default.
//
enum
class
async_overflow_policy
{
block_retry
,
// Block / yield / sleep until message can be enqueued
discard_log_msg
// Discard the message it enqueue fails
};
//
// Log exception
//
...
...
include/spdlog/details/async_log_helper.h
View file @
89afa909
...
...
@@ -112,7 +112,7 @@ public:
async_log_helper
(
formatter_ptr
formatter
,
const
std
::
vector
<
sink_ptr
>&
sinks
,
size_t
queue_size
,
const
async_
queue_overflow_policy
overflow_policy
=
async_queue
_overflow_policy
::
block_retry
,
const
async_
overflow_policy
overflow_policy
=
async
_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
void
log
(
const
details
::
log_msg
&
msg
);
...
...
@@ -133,7 +133,7 @@ private:
std
::
shared_ptr
<
spdlog_ex
>
_last_workerthread_ex
;
// overflow policy
const
async_
queue_
overflow_policy
_overflow_policy
;
const
async_overflow_policy
_overflow_policy
;
// worker thread warmup callback - one can set thread priority, affinity, etc
const
std
::
function
<
void
()
>
_worker_warmup_cb
;
...
...
@@ -161,7 +161,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
// async_sink class implementation
///////////////////////////////////////////////////////////////////////////////
inline
spdlog
::
details
::
async_log_helper
::
async_log_helper
(
formatter_ptr
formatter
,
const
std
::
vector
<
sink_ptr
>&
sinks
,
size_t
queue_size
,
const
async_
queue_
overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
inline
spdlog
::
details
::
async_log_helper
::
async_log_helper
(
formatter_ptr
formatter
,
const
std
::
vector
<
sink_ptr
>&
sinks
,
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
_formatter
(
formatter
),
_sinks
(
sinks
),
_q
(
queue_size
),
...
...
@@ -190,7 +190,7 @@ inline void spdlog::details::async_log_helper::log(const details::log_msg& msg)
{
throw_if_bad_worker
();
async_msg
new_msg
(
msg
);
if
(
!
_q
.
enqueue
(
std
::
move
(
new_msg
))
&&
_overflow_policy
!=
async_
queue_
overflow_policy
::
discard_log_msg
)
if
(
!
_q
.
enqueue
(
std
::
move
(
new_msg
))
&&
_overflow_policy
!=
async_overflow_policy
::
discard_log_msg
)
{
auto
last_op_time
=
clock
::
now
();
do
...
...
include/spdlog/details/async_logger_impl.h
View file @
89afa909
...
...
@@ -34,16 +34,16 @@
template
<
class
It
>
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
const
It
&
begin
,
const
It
&
end
,
size_t
queue_size
,
const
async_queue
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
const
It
&
begin
,
const
It
&
end
,
size_t
queue_size
,
const
async
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
logger
(
logger_name
,
begin
,
end
),
_async_log_helper
(
new
details
::
async_log_helper
(
_formatter
,
_sinks
,
queue_size
,
overflow_policy
,
worker_warmup_cb
))
{
}
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
,
size_t
queue_size
,
const
async_queue
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
,
size_t
queue_size
,
const
async
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
async_logger
(
logger_name
,
sinks
.
begin
(),
sinks
.
end
(),
queue_size
,
overflow_policy
,
worker_warmup_cb
)
{}
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
sink_ptr
single_sink
,
size_t
queue_size
,
const
async_queue
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
inline
spdlog
::
async_logger
::
async_logger
(
const
std
::
string
&
logger_name
,
sink_ptr
single_sink
,
size_t
queue_size
,
const
async
_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
:
async_logger
(
logger_name
,
{
single_sink
},
queue_size
,
overflow_policy
,
worker_warmup_cb
)
{}
...
...
include/spdlog/details/registry.h
View file @
89afa909
...
...
@@ -120,7 +120,7 @@ public:
l
.
second
->
set_level
(
log_level
);
}
void
set_async_mode
(
size_t
q_size
,
const
async_
queue_
overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
void
set_async_mode
(
size_t
q_size
,
const
async_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
_async_mode
=
true
;
...
...
@@ -152,7 +152,7 @@ private:
level
::
level_enum
_level
=
level
::
info
;
bool
_async_mode
=
false
;
size_t
_async_q_size
=
0
;
async_
queue_overflow_policy
_overflow_policy
=
async_queue
_overflow_policy
::
block_retry
;
async_
overflow_policy
_overflow_policy
=
async
_overflow_policy
::
block_retry
;
std
::
function
<
void
()
>
_worker_warmup_cb
=
nullptr
;
};
}
...
...
include/spdlog/details/spdlog_impl.h
View file @
89afa909
...
...
@@ -132,7 +132,7 @@ inline void spdlog::set_level(level::level_enum log_level)
}
inline
void
spdlog
::
set_async_mode
(
size_t
queue_size
,
const
async_
queue_
overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
inline
void
spdlog
::
set_async_mode
(
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
)
{
details
::
registry
::
instance
().
set_async_mode
(
queue_size
,
overflow_policy
,
worker_warmup_cb
);
}
...
...
include/spdlog/spdlog.h
View file @
89afa909
...
...
@@ -57,19 +57,8 @@ void set_formatter(formatter_ptr f);
void
set_level
(
level
::
level_enum
log_level
);
//
// Async mode - off by default.
//
enum
class
async_queue_overflow_policy
{
block_retry
,
// Block / yield / sleep until message can be enqueued
discard_log_msg
// Discard the message it enqueue fails
};
// Turn on async mode and set the queue size for each async_logger
void
set_async_mode
(
size_t
queue_size
,
const
async_queue_overflow_policy
overflow_policy
=
async_queue_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
void
set_async_mode
(
size_t
queue_size
,
const
async_overflow_policy
overflow_policy
=
async_overflow_policy
::
block_retry
,
const
std
::
function
<
void
()
>&
worker_warmup_cb
=
nullptr
);
// Turn off async mode
void
set_sync_mode
();
...
...
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