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
2848e517
Commit
2848e517
authored
Aug 23, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean log_msg_buffer
parent
0db49788
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
40 deletions
+10
-40
include/spdlog/details/log_msg_buffer.h
include/spdlog/details/log_msg_buffer.h
+10
-40
No files found.
include/spdlog/details/log_msg_buffer.h
View file @
2848e517
...
@@ -9,56 +9,26 @@
...
@@ -9,56 +9,26 @@
namespace
spdlog
{
namespace
spdlog
{
namespace
details
{
namespace
details
{
// regular log_msgs hold string_views to stack data - so they cannot be stored for later use.
// extend log_msg with internal buffer to store its payload.
// this one can, since it contains and owns the payload buffer.
// this is needed since log_msg holds string_views that points to stack data.
struct
log_msg_buffer
:
log_msg
struct
log_msg_buffer
:
log_msg
{
{
fmt
::
basic_memory_buffer
<
char
,
40
>
loggername_buf
;
fmt
::
basic_memory_buffer
<
char
,
200
>
buffer
;
fmt
::
basic_memory_buffer
<
char
,
200
>
payload_buf
;
log_msg_buffer
()
=
default
;
log_msg_buffer
()
=
default
;
explicit
log_msg_buffer
(
const
log_msg
&
orig_msg
)
explicit
log_msg_buffer
(
const
log_msg
&
orig_msg
)
:
log_msg
(
orig_msg
)
:
log_msg
(
orig_msg
)
{
{
update_buffers
();
buffer
.
append
(
logger_name
.
begin
(),
logger_name
.
end
());
}
logger_name
=
string_view_t
{
buffer
.
data
(),
buffer
.
size
()};
log_msg_buffer
(
const
log_msg_buffer
&
other
)
:
log_msg
(
other
)
{
update_buffers
();
}
log_msg_buffer
(
const
log_msg_buffer
&&
other
)
SPDLOG_NOEXCEPT
buffer
.
append
(
payload
.
begin
(),
payload
.
end
());
:
log_msg
(
std
::
move
(
other
))
payload
=
string_view_t
{
logger_name
.
end
(),
payload
.
size
()};
{
update_buffers
();
}
}
log_msg_buffer
&
operator
=
(
const
log_msg_buffer
&
other
)
SPDLOG_NOEXCEPT
log_msg_buffer
(
log_msg_buffer
&&
other
)
=
default
;
{
log_msg_buffer
&
operator
=
(
log_msg_buffer
&&
other
)
=
default
;
*
static_cast
<
log_msg
*>
(
this
)
=
other
;
update_buffers
();
return
*
this
;
}
log_msg_buffer
&
operator
=
(
log_msg_buffer
&&
other
)
SPDLOG_NOEXCEPT
{
*
static_cast
<
log_msg
*>
(
this
)
=
std
::
move
(
other
);
update_buffers
();
return
*
this
;
}
void
update_buffers
()
SPDLOG_NOEXCEPT
{
loggername_buf
.
clear
();
loggername_buf
.
append
(
logger_name
.
data
(),
logger_name
.
data
()
+
logger_name
.
size
());
logger_name
=
string_view_t
{
loggername_buf
.
data
(),
loggername_buf
.
size
()};
payload_buf
.
clear
();
payload_buf
.
append
(
payload
.
data
(),
payload
.
data
()
+
payload
.
size
());
payload
=
string_view_t
{
payload_buf
.
data
(),
payload_buf
.
size
()};
}
};
};
}
// namespace details
}
// namespace details
...
...
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