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
b4dd3718
Commit
b4dd3718
authored
Dec 04, 2021
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed example for std_format
parent
c3b1aaa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
example/example.cpp
example/example.cpp
+16
-7
No files found.
example/example.cpp
View file @
b4dd3718
...
...
@@ -181,14 +181,20 @@ void binary_example()
}
// Log a vector of numbers
#include "spdlog/fmt/bundled/ranges.h"
#ifndef SPDLOG_USE_STD_FORMAT
#
include "spdlog/fmt/bundled/ranges.h"
void
vector_example
()
{
std
::
vector
<
int
>
vec
=
{
1
,
2
,
3
};
spdlog
::
info
(
"Vector example: {}"
,
vec
);
}
#else
void
vector_example
()
{}
#endif
// ! DSPDLOG_USE_STD_FORMAT
// Compile time log levels.
// define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE)
void
trace_example
()
...
...
@@ -242,10 +248,14 @@ void multi_sink_example()
struct
my_type
{
int
i
;
template
<
typename
OStream
>
friend
OStream
&
operator
<<
(
OStream
&
os
,
const
my_type
&
c
)
};
template
<
>
struct
std
::
formatter
<
my_type
>
:
std
::
formatter
<
std
::
string
>
{
auto
format
(
my_type
my
,
format_context
&
ctx
)
{
return
os
<<
"[my_type i="
<<
c
.
i
<<
"]"
;
return
formatter
<
string
>::
format
(
std
::
format
(
"[my_type i={}]"
,
my
.
i
),
ctx
)
;
}
};
...
...
@@ -303,10 +313,9 @@ public:
};
void
custom_formatter_flag_example
()
{
{
auto
formatter
=
make_unique
<
spdlog
::
pattern_formatter
>
(
""
);
formatter
->
add_flag
<
my_formatter_flag
>
(
'*'
).
set_pattern
(
"[%*] [%^%l%$] %v"
);
spdlog
::
default_logger
()
->
set_formatter
(
std
::
move
(
formatter
));
spdlog
::
info
(
"Custom flag example"
);
}
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