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
7b14a65b
Commit
7b14a65b
authored
Jun 24, 2021
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed format_to deprecated warning by wrapping the buffer with std::back_inserter
parent
5887744d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
9 deletions
+13
-9
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+2
-1
include/spdlog/logger.h
include/spdlog/logger.h
+4
-2
include/spdlog/sinks/dup_filter_sink.h
include/spdlog/sinks/dup_filter_sink.h
+1
-1
tests/test_daily_logger.cpp
tests/test_daily_logger.cpp
+4
-3
tests/test_file_helper.cpp
tests/test_file_helper.cpp
+1
-1
tests/test_pattern_formatter.cpp
tests/test_pattern_formatter.cpp
+1
-1
No files found.
include/spdlog/details/fmt_helper.h
View file @
7b14a65b
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <chrono>
#include <chrono>
#include <type_traits>
#include <type_traits>
#include <iterator>
#include <spdlog/fmt/fmt.h>
#include <spdlog/fmt/fmt.h>
#include <spdlog/common.h>
#include <spdlog/common.h>
...
@@ -54,7 +55,7 @@ inline void pad2(int n, memory_buf_t &dest)
...
@@ -54,7 +55,7 @@ inline void pad2(int n, memory_buf_t &dest)
}
}
else
// unlikely, but just in case, let fmt deal with it
else
// unlikely, but just in case, let fmt deal with it
{
{
fmt
::
format_to
(
dest
,
"{:02}"
,
n
);
fmt
::
format_to
(
std
::
back_inserter
(
dest
)
,
"{:02}"
,
n
);
}
}
}
}
...
...
include/spdlog/logger.h
View file @
7b14a65b
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#endif
#endif
#include <vector>
#include <vector>
#include <iterator>
#ifndef SPDLOG_NO_EXCEPTIONS
#ifndef SPDLOG_NO_EXCEPTIONS
#define SPDLOG_LOGGER_CATCH() \
#define SPDLOG_LOGGER_CATCH() \
catch (const std::exception &ex) \
catch (const std::exception &ex) \
...
@@ -238,7 +240,7 @@ public:
...
@@ -238,7 +240,7 @@ public:
{
{
// format to wmemory_buffer and convert to utf8
// format to wmemory_buffer and convert to utf8
fmt
::
wmemory_buffer
wbuf
;
fmt
::
wmemory_buffer
wbuf
;
fmt
::
format_to
(
wbuf
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
fmt
::
format_to
(
std
::
back_inserter
(
wbuf
)
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
memory_buf_t
buf
;
memory_buf_t
buf
;
details
::
os
::
wstr_to_utf8buf
(
wstring_view_t
(
wbuf
.
data
(),
wbuf
.
size
()),
buf
);
details
::
os
::
wstr_to_utf8buf
(
wstring_view_t
(
wbuf
.
data
(),
wbuf
.
size
()),
buf
);
...
@@ -338,7 +340,7 @@ protected:
...
@@ -338,7 +340,7 @@ protected:
SPDLOG_TRY
SPDLOG_TRY
{
{
memory_buf_t
buf
;
memory_buf_t
buf
;
fmt
::
format_to
(
buf
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
fmt
::
format_to
(
std
::
back_inserter
(
buf
)
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
}
}
...
...
include/spdlog/sinks/dup_filter_sink.h
View file @
7b14a65b
...
@@ -63,7 +63,7 @@ protected:
...
@@ -63,7 +63,7 @@ protected:
if
(
skip_counter_
>
0
)
if
(
skip_counter_
>
0
)
{
{
memory_buf_t
buf
;
memory_buf_t
buf
;
fmt
::
format_to
(
buf
,
"Skipped {} duplicate messages.."
,
skip_counter_
);
fmt
::
format_to
(
std
::
back_inserter
(
buf
)
,
"Skipped {} duplicate messages.."
,
skip_counter_
);
details
::
log_msg
skipped_msg
{
msg
.
logger_name
,
level
::
info
,
string_view_t
{
buf
.
data
(),
buf
.
size
()}};
details
::
log_msg
skipped_msg
{
msg
.
logger_name
,
level
::
info
,
string_view_t
{
buf
.
data
(),
buf
.
size
()}};
dist_sink
<
Mutex
>::
sink_it_
(
skipped_msg
);
dist_sink
<
Mutex
>::
sink_it_
(
skipped_msg
);
}
}
...
...
tests/test_daily_logger.cpp
View file @
7b14a65b
...
@@ -15,7 +15,7 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]")
...
@@ -15,7 +15,7 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]")
spdlog
::
filename_t
basename
=
SPDLOG_FILENAME_T
(
"test_logs/daily_dateonly"
);
spdlog
::
filename_t
basename
=
SPDLOG_FILENAME_T
(
"test_logs/daily_dateonly"
);
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
filename_memory_buf_t
w
;
filename_memory_buf_t
w
;
fmt
::
format_to
(
w
,
SPDLOG_FILENAME_T
(
"{}_{:04d}-{:02d}-{:02d}"
),
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
fmt
::
format_to
(
std
::
back_inserter
(
w
)
,
SPDLOG_FILENAME_T
(
"{}_{:04d}-{:02d}-{:02d}"
),
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
auto
logger
=
spdlog
::
create
<
sink_type
>
(
"logger"
,
basename
,
0
,
0
);
auto
logger
=
spdlog
::
create
<
sink_type
>
(
"logger"
,
basename
,
0
,
0
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
for
(
int
i
=
0
;
i
<
10
;
++
i
)
...
@@ -40,7 +40,8 @@ struct custom_daily_file_name_calculator
...
@@ -40,7 +40,8 @@ struct custom_daily_file_name_calculator
static
spdlog
::
filename_t
calc_filename
(
const
spdlog
::
filename_t
&
basename
,
const
tm
&
now_tm
)
static
spdlog
::
filename_t
calc_filename
(
const
spdlog
::
filename_t
&
basename
,
const
tm
&
now_tm
)
{
{
filename_memory_buf_t
w
;
filename_memory_buf_t
w
;
fmt
::
format_to
(
w
,
SPDLOG_FILENAME_T
(
"{}{:04d}{:02d}{:02d}"
),
basename
,
now_tm
.
tm_year
+
1900
,
now_tm
.
tm_mon
+
1
,
now_tm
.
tm_mday
);
fmt
::
format_to
(
std
::
back_inserter
(
w
),
SPDLOG_FILENAME_T
(
"{}{:04d}{:02d}{:02d}"
),
basename
,
now_tm
.
tm_year
+
1900
,
now_tm
.
tm_mon
+
1
,
now_tm
.
tm_mday
);
return
fmt
::
to_string
(
w
);
return
fmt
::
to_string
(
w
);
}
}
};
};
...
@@ -55,7 +56,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]")
...
@@ -55,7 +56,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]")
spdlog
::
filename_t
basename
=
SPDLOG_FILENAME_T
(
"test_logs/daily_dateonly"
);
spdlog
::
filename_t
basename
=
SPDLOG_FILENAME_T
(
"test_logs/daily_dateonly"
);
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
filename_memory_buf_t
w
;
filename_memory_buf_t
w
;
fmt
::
format_to
(
w
,
SPDLOG_FILENAME_T
(
"{}{:04d}{:02d}{:02d}"
),
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
fmt
::
format_to
(
std
::
back_inserter
(
w
)
,
SPDLOG_FILENAME_T
(
"{}{:04d}{:02d}{:02d}"
),
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
auto
logger
=
spdlog
::
create
<
sink_type
>
(
"logger"
,
basename
,
0
,
0
);
auto
logger
=
spdlog
::
create
<
sink_type
>
(
"logger"
,
basename
,
0
,
0
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
for
(
int
i
=
0
;
i
<
10
;
++
i
)
...
...
tests/test_file_helper.cpp
View file @
7b14a65b
...
@@ -10,7 +10,7 @@ using spdlog::details::file_helper;
...
@@ -10,7 +10,7 @@ using spdlog::details::file_helper;
static
void
write_with_helper
(
file_helper
&
helper
,
size_t
howmany
)
static
void
write_with_helper
(
file_helper
&
helper
,
size_t
howmany
)
{
{
spdlog
::
memory_buf_t
formatted
;
spdlog
::
memory_buf_t
formatted
;
fmt
::
format_to
(
formatted
,
"{}"
,
std
::
string
(
howmany
,
'1'
));
fmt
::
format_to
(
std
::
back_inserter
(
formatted
)
,
"{}"
,
std
::
string
(
howmany
,
'1'
));
helper
.
write
(
formatted
);
helper
.
write
(
formatted
);
helper
.
flush
();
helper
.
flush
();
}
}
...
...
tests/test_pattern_formatter.cpp
View file @
7b14a65b
...
@@ -64,7 +64,7 @@ TEST_CASE("color range test1", "[pattern_formatter]")
...
@@ -64,7 +64,7 @@ TEST_CASE("color range test1", "[pattern_formatter]")
auto
formatter
=
std
::
make_shared
<
spdlog
::
pattern_formatter
>
(
"%^%v%$"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
);
auto
formatter
=
std
::
make_shared
<
spdlog
::
pattern_formatter
>
(
"%^%v%$"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
);
memory_buf_t
buf
;
memory_buf_t
buf
;
fmt
::
format_to
(
buf
,
"Hello"
);
fmt
::
format_to
(
std
::
back_inserter
(
buf
)
,
"Hello"
);
memory_buf_t
formatted
;
memory_buf_t
formatted
;
std
::
string
logger_name
=
"test"
;
std
::
string
logger_name
=
"test"
;
spdlog
::
details
::
log_msg
msg
(
logger_name
,
spdlog
::
level
::
info
,
spdlog
::
string_view_t
(
buf
.
data
(),
buf
.
size
()));
spdlog
::
details
::
log_msg
msg
(
logger_name
,
spdlog
::
level
::
info
,
spdlog
::
string_view_t
(
buf
.
data
(),
buf
.
size
()));
...
...
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