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
a6e2f237
Commit
a6e2f237
authored
Jun 26, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pattern formatter optimizations
parent
87e01353
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
228 additions
and
248 deletions
+228
-248
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+9
-8
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+219
-218
include/spdlog/formatter.h
include/spdlog/formatter.h
+0
-22
No files found.
include/spdlog/details/fmt_helper.h
View file @
a6e2f237
...
@@ -26,17 +26,13 @@ inline void append_buf(const fmt::memory_buffer &buf, fmt::memory_buffer &dest)
...
@@ -26,17 +26,13 @@ inline void append_buf(const fmt::memory_buffer &buf, fmt::memory_buffer &dest)
dest
.
append
(
buf_ptr
,
buf_ptr
+
buf
.
size
());
dest
.
append
(
buf_ptr
,
buf_ptr
+
buf
.
size
());
}
}
inline
void
append_int
(
int
n
,
fmt
::
memory_buffer
&
dest
)
template
<
typename
T
>
inline
void
append_int
(
T
n
,
fmt
::
memory_buffer
&
dest
)
{
{
fmt
::
format_int
i
(
n
);
fmt
::
format_int
i
(
n
);
dest
.
append
(
i
.
data
(),
i
.
data
()
+
i
.
size
());
dest
.
append
(
i
.
data
(),
i
.
data
()
+
i
.
size
());
}
}
inline
void
append_size_t
(
size_t
n
,
fmt
::
memory_buffer
&
dest
)
{
fmt
::
format_int
i
(
n
);
dest
.
append
(
i
.
data
(),
i
.
data
()
+
i
.
size
());
}
inline
void
append_and_pad2
(
int
n
,
fmt
::
memory_buffer
&
dest
)
inline
void
append_and_pad2
(
int
n
,
fmt
::
memory_buffer
&
dest
)
{
{
...
@@ -64,12 +60,17 @@ inline void append_and_pad3(int n, fmt::memory_buffer &dest)
...
@@ -64,12 +60,17 @@ inline void append_and_pad3(int n, fmt::memory_buffer &dest)
}
}
if
(
n
>
9
)
// 10-99
if
(
n
>
9
)
// 10-99
{
{
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
+
n
/
10
);
dest
.
push_back
(
'0'
+
n
%
10
);
return
;
}
}
else
if
(
n
>=
0
)
else
if
(
n
>=
0
)
{
{
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
+
n
);
return
;
}
}
// negatives (unlikely, but just in case let fmt deal with it)
// negatives (unlikely, but just in case let fmt deal with it)
else
else
...
@@ -77,7 +78,7 @@ inline void append_and_pad3(int n, fmt::memory_buffer &dest)
...
@@ -77,7 +78,7 @@ inline void append_and_pad3(int n, fmt::memory_buffer &dest)
fmt
::
format_to
(
dest
,
"{:03}"
,
n
);
fmt
::
format_to
(
dest
,
"{:03}"
,
n
);
return
;
return
;
}
}
append_int
(
n
,
dest
);
}
}
inline
void
append_and_pad6
(
int
n
,
fmt
::
memory_buffer
&
dest
)
inline
void
append_and_pad6
(
int
n
,
fmt
::
memory_buffer
&
dest
)
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
a6e2f237
This diff is collapsed.
Click to expand it.
include/spdlog/formatter.h
View file @
a6e2f237
...
@@ -20,28 +20,6 @@ public:
...
@@ -20,28 +20,6 @@ public:
virtual
~
formatter
()
=
default
;
virtual
~
formatter
()
=
default
;
virtual
void
format
(
const
details
::
log_msg
&
msg
,
fmt
::
memory_buffer
&
dest
)
=
0
;
virtual
void
format
(
const
details
::
log_msg
&
msg
,
fmt
::
memory_buffer
&
dest
)
=
0
;
};
};
namespace
details
{
class
flag_formatter
;
}
class
pattern_formatter
SPDLOG_FINAL
:
public
formatter
{
public:
explicit
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
=
pattern_time_type
::
local
,
std
::
string
eol
=
spdlog
::
details
::
os
::
default_eol
);
pattern_formatter
(
const
pattern_formatter
&
)
=
default
;
pattern_formatter
&
operator
=
(
const
pattern_formatter
&
)
=
default
;
void
format
(
const
details
::
log_msg
&
msg
,
fmt
::
memory_buffer
&
dest
)
override
;
private:
const
std
::
string
eol_
;
const
pattern_time_type
pattern_time_
;
std
::
vector
<
std
::
unique_ptr
<
details
::
flag_formatter
>>
formatters_
;
std
::
tm
get_time
(
const
details
::
log_msg
&
msg
);
void
handle_flag
(
char
flag
);
void
compile_pattern
(
const
std
::
string
&
pattern
);
};
}
// namespace spdlog
}
// namespace spdlog
#include "details/pattern_formatter_impl.h"
#include "details/pattern_formatter_impl.h"
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