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
0a5ada64
Commit
0a5ada64
authored
Mar 21, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format
parent
963f8d34
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
example/example.cpp
example/example.cpp
+5
-6
include/spdlog/pattern_formatter-inl.h
include/spdlog/pattern_formatter-inl.h
+2
-2
tests/test_pattern_formatter.cpp
tests/test_pattern_formatter.cpp
+4
-2
No files found.
example/example.cpp
View file @
0a5ada64
...
@@ -254,7 +254,6 @@ void android_example()
...
@@ -254,7 +254,6 @@ void android_example()
}
}
#endif
#endif
// Log patterns can contain custom flags.
// Log patterns can contain custom flags.
// this will add custom flag '%*' which will be bound to a <my_formatter_flag> instance
// this will add custom flag '%*' which will be bound to a <my_formatter_flag> instance
#include "spdlog/pattern_formatter.h"
#include "spdlog/pattern_formatter.h"
...
@@ -274,10 +273,10 @@ public:
...
@@ -274,10 +273,10 @@ public:
};
};
void
custom_flags_example
()
void
custom_flags_example
()
{
{
using
spdlog
::
details
::
make_unique
;
// for pre c++14
using
spdlog
::
details
::
make_unique
;
// for pre c++14
auto
formatter
=
make_unique
<
spdlog
::
pattern_formatter
>
();
auto
formatter
=
make_unique
<
spdlog
::
pattern_formatter
>
();
formatter
->
add_flag
<
my_formatter_flag
>
(
'*'
).
set_pattern
(
"[%n] [%*] [%^%l%$] %v"
);
formatter
->
add_flag
<
my_formatter_flag
>
(
'*'
).
set_pattern
(
"[%n] [%*] [%^%l%$] %v"
);
spdlog
::
set_formatter
(
std
::
move
(
formatter
));
spdlog
::
set_formatter
(
std
::
move
(
formatter
));
}
}
include/spdlog/pattern_formatter-inl.h
View file @
0a5ada64
...
@@ -1044,7 +1044,7 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
...
@@ -1044,7 +1044,7 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
{
{
// process custom flags
// process custom flags
auto
it
=
custom_handlers_
.
find
(
flag
);
auto
it
=
custom_handlers_
.
find
(
flag
);
if
(
it
!=
custom_handlers_
.
end
())
if
(
it
!=
custom_handlers_
.
end
())
{
{
auto
custom_handler
=
it
->
second
->
clone
();
auto
custom_handler
=
it
->
second
->
clone
();
custom_handler
->
set_padding_info
(
padding
);
custom_handler
->
set_padding_info
(
padding
);
...
@@ -1053,7 +1053,7 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
...
@@ -1053,7 +1053,7 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
}
}
// process built-in flags
// process built-in flags
switch
(
flag
)
switch
(
flag
)
{
{
case
(
'+'
):
// default formatter
case
(
'+'
):
// default formatter
formatters_
.
push_back
(
details
::
make_unique
<
details
::
full_formatter
>
(
padding
));
formatters_
.
push_back
(
details
::
make_unique
<
details
::
full_formatter
>
(
padding
));
...
...
tests/test_pattern_formatter.cpp
View file @
0a5ada64
...
@@ -308,7 +308,9 @@ TEST_CASE("clone-formatter-2", "[pattern_formatter]")
...
@@ -308,7 +308,9 @@ TEST_CASE("clone-formatter-2", "[pattern_formatter]")
class
custom_test_flag
:
public
spdlog
::
custom_flag_formatter
class
custom_test_flag
:
public
spdlog
::
custom_flag_formatter
{
{
public:
public:
custom_test_flag
(
std
::
string
txt
)
:
some_txt
{
std
::
move
(
txt
)}
{}
custom_test_flag
(
std
::
string
txt
)
:
some_txt
{
std
::
move
(
txt
)}
{}
void
format
(
const
spdlog
::
details
::
log_msg
&
,
const
std
::
tm
&
,
spdlog
::
memory_buf_t
&
dest
)
override
void
format
(
const
spdlog
::
details
::
log_msg
&
,
const
std
::
tm
&
,
spdlog
::
memory_buf_t
&
dest
)
override
{
{
...
@@ -316,7 +318,7 @@ public:
...
@@ -316,7 +318,7 @@ public:
{
{
throw
spdlog
::
spdlog_ex
(
"custom_flag_exception_test"
);
throw
spdlog
::
spdlog_ex
(
"custom_flag_exception_test"
);
}
}
some_txt
=
std
::
string
(
padinfo_
.
width_
,
' '
)
+
some_txt
;
some_txt
=
std
::
string
(
padinfo_
.
width_
,
' '
)
+
some_txt
;
dest
.
append
(
some_txt
.
data
(),
some_txt
.
data
()
+
some_txt
.
size
());
dest
.
append
(
some_txt
.
data
(),
some_txt
.
data
()
+
some_txt
.
size
());
}
}
spdlog
::
details
::
padding_info
get_padding_info
()
spdlog
::
details
::
padding_info
get_padding_info
()
...
...
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