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
36112371
Commit
36112371
authored
Oct 05, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted const qualifier to log_msg& args, fixed issue #849, and added counter tests
parent
2fa53877
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
10 deletions
+28
-10
include/spdlog/async_logger.h
include/spdlog/async_logger.h
+1
-1
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+2
-2
include/spdlog/details/log_msg.h
include/spdlog/details/log_msg.h
+3
-2
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+1
-1
include/spdlog/details/thread_pool.h
include/spdlog/details/thread_pool.h
+3
-3
include/spdlog/logger.h
include/spdlog/logger.h
+1
-1
tests/includes.h
tests/includes.h
+1
-0
tests/test_misc.cpp
tests/test_misc.cpp
+16
-0
No files found.
include/spdlog/async_logger.h
View file @
36112371
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
new_name
)
override
;
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
new_name
)
override
;
protected:
protected:
void
sink_it_
(
const
details
::
log_msg
&
msg
)
override
;
void
sink_it_
(
details
::
log_msg
&
msg
)
override
;
void
flush_
()
override
;
void
flush_
()
override
;
void
backend_log_
(
const
details
::
log_msg
&
incoming_log_msg
);
void
backend_log_
(
const
details
::
log_msg
&
incoming_log_msg
);
...
...
include/spdlog/details/async_logger_impl.h
View file @
36112371
...
@@ -36,14 +36,14 @@ inline spdlog::async_logger::async_logger(
...
@@ -36,14 +36,14 @@ inline spdlog::async_logger::async_logger(
}
}
// send the log message to the thread pool
// send the log message to the thread pool
inline
void
spdlog
::
async_logger
::
sink_it_
(
const
details
::
log_msg
&
msg
)
inline
void
spdlog
::
async_logger
::
sink_it_
(
details
::
log_msg
&
msg
)
{
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
incr_msg_counter_
(
msg
);
incr_msg_counter_
(
msg
);
#endif
#endif
if
(
auto
pool_ptr
=
thread_pool_
.
lock
())
if
(
auto
pool_ptr
=
thread_pool_
.
lock
())
{
{
pool_ptr
->
post_log
(
shared_from_this
(),
msg
,
overflow_policy_
);
pool_ptr
->
post_log
(
shared_from_this
(),
std
::
move
(
msg
)
,
overflow_policy_
);
}
}
else
else
{
{
...
...
include/spdlog/details/log_msg.h
View file @
36112371
...
@@ -39,8 +39,9 @@ struct log_msg
...
@@ -39,8 +39,9 @@ struct log_msg
log_clock
::
time_point
time
;
log_clock
::
time_point
time
;
size_t
thread_id
;
size_t
thread_id
;
fmt
::
memory_buffer
raw
;
fmt
::
memory_buffer
raw
;
mutable
size_t
msg_id
{
0
};
size_t
msg_id
{
0
};
// info about wrapping the formatted text with color
// info about wrapping the formatted text with color (updated by pattern_formatter).
mutable
size_t
color_range_start
{
0
};
mutable
size_t
color_range_start
{
0
};
mutable
size_t
color_range_end
{
0
};
mutable
size_t
color_range_end
{
0
};
};
};
...
...
include/spdlog/details/logger_impl.h
View file @
36112371
...
@@ -317,7 +317,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
...
@@ -317,7 +317,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
// protected virtual called at end of each user log call (if enabled) by the
// protected virtual called at end of each user log call (if enabled) by the
// line_logger
// line_logger
//
//
inline
void
spdlog
::
logger
::
sink_it_
(
const
details
::
log_msg
&
msg
)
inline
void
spdlog
::
logger
::
sink_it_
(
details
::
log_msg
&
msg
)
{
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
incr_msg_counter_
(
msg
);
incr_msg_counter_
(
msg
);
...
...
include/spdlog/details/thread_pool.h
View file @
36112371
...
@@ -69,7 +69,7 @@ struct async_msg
...
@@ -69,7 +69,7 @@ struct async_msg
#endif
#endif
// construct from log_msg with given type
// construct from log_msg with given type
async_msg
(
async_logger_ptr
&&
worker
,
async_msg_type
the_type
,
const
details
::
log_msg
&
m
)
async_msg
(
async_logger_ptr
&&
worker
,
async_msg_type
the_type
,
details
::
log_msg
&
&
m
)
:
msg_type
(
the_type
)
:
msg_type
(
the_type
)
,
level
(
m
.
level
)
,
level
(
m
.
level
)
,
time
(
m
.
time
)
,
time
(
m
.
time
)
...
@@ -149,9 +149,9 @@ public:
...
@@ -149,9 +149,9 @@ public:
thread_pool
(
const
thread_pool
&
)
=
delete
;
thread_pool
(
const
thread_pool
&
)
=
delete
;
thread_pool
&
operator
=
(
thread_pool
&&
)
=
delete
;
thread_pool
&
operator
=
(
thread_pool
&&
)
=
delete
;
void
post_log
(
async_logger_ptr
&&
worker_ptr
,
const
details
::
log_msg
&
msg
,
async_overflow_policy
overflow_policy
)
void
post_log
(
async_logger_ptr
&&
worker_ptr
,
details
::
log_msg
&
&
msg
,
async_overflow_policy
overflow_policy
)
{
{
async_msg
async_m
(
std
::
forward
<
async_logger_ptr
>
(
worker_ptr
),
async_msg_type
::
log
,
msg
);
async_msg
async_m
(
std
::
forward
<
async_logger_ptr
>
(
worker_ptr
),
async_msg_type
::
log
,
std
::
forward
<
log_msg
>
(
msg
)
);
post_async_msg_
(
std
::
move
(
async_m
),
overflow_policy
);
post_async_msg_
(
std
::
move
(
async_m
),
overflow_policy
);
}
}
...
...
include/spdlog/logger.h
View file @
36112371
...
@@ -142,7 +142,7 @@ public:
...
@@ -142,7 +142,7 @@ public:
virtual
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
logger_name
);
virtual
std
::
shared_ptr
<
logger
>
clone
(
std
::
string
logger_name
);
protected:
protected:
virtual
void
sink_it_
(
const
details
::
log_msg
&
msg
);
virtual
void
sink_it_
(
details
::
log_msg
&
msg
);
virtual
void
flush_
();
virtual
void
flush_
();
bool
should_flush_
(
const
details
::
log_msg
&
msg
);
bool
should_flush_
(
const
details
::
log_msg
&
msg
);
...
...
tests/includes.h
View file @
36112371
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#define SPDLOG_TRACE_ON
#define SPDLOG_TRACE_ON
#define SPDLOG_DEBUG_ON
#define SPDLOG_DEBUG_ON
#define SPDLOG_ENABLE_MESSAGE_COUNTER
#include "spdlog/async.h"
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
...
...
tests/test_misc.cpp
View file @
36112371
...
@@ -175,3 +175,19 @@ TEST_CASE("to_hex_no_delimiter", "[to_hex]")
...
@@ -175,3 +175,19 @@ TEST_CASE("to_hex_no_delimiter", "[to_hex]")
auto
output
=
oss
.
str
();
auto
output
=
oss
.
str
();
REQUIRE
(
ends_with
(
output
,
"0000: 090A0B0CFFFF"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
REQUIRE
(
ends_with
(
output
,
"0000: 090A0B0CFFFF"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
}
}
TEST_CASE
(
"message_counter"
,
"[message_counter]"
)
{
std
::
ostringstream
oss
;
auto
oss_sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ostream_sink_mt
>
(
oss
);
spdlog
::
logger
oss_logger
(
"oss"
,
oss_sink
);
oss_logger
.
set_pattern
(
"%i %v"
);
oss_logger
.
info
(
"Hello"
);
REQUIRE
(
oss
.
str
()
==
"000001 Hello"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
));
oss
.
str
(
""
);
oss_logger
.
info
(
"Hello again"
);
REQUIRE
(
oss
.
str
()
==
"000002 Hello again"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
));
}
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