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
81fa788b
Commit
81fa788b
authored
Jun 12, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated tests
parent
cdbf2e36
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
23 deletions
+18
-23
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+0
-7
tests/Makefile
tests/Makefile
+1
-1
tests/file_helper.cpp
tests/file_helper.cpp
+2
-1
tests/file_log.cpp
tests/file_log.cpp
+13
-12
tests/test_pattern_formatter.cpp
tests/test_pattern_formatter.cpp
+2
-2
No files found.
include/spdlog/tweakme.h
View file @
81fa788b
...
...
@@ -95,13 +95,6 @@
// #define SPDLOG_FMT_EXTERNAL
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to use printf-style messages in your logs instead of the usual
// format-style used by default.
//
// #define SPDLOG_FMT_PRINTF
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable wchar_t support (convert to utf8)
//
...
...
tests/Makefile
View file @
81fa788b
CXX
?=
g++
CXXFLAGS
=
-Wall
-pedantic
-std
=
c++11
-pthread
-O3
-I
../include
CXXFLAGS
=
-Wall
-pedantic
-std
=
c++11
-pthread
-O3
-I
../include
-fmax-errors
=
1
LDPFALGS
=
-pthread
CPP_FILES
:=
$(
wildcard
*
.cpp
)
...
...
tests/file_helper.cpp
View file @
81fa788b
...
...
@@ -11,7 +11,8 @@ static const std::string target_filename = "logs/file_helper_test.txt";
static
void
write_with_helper
(
file_helper
&
helper
,
size_t
howmany
)
{
log_msg
msg
;
msg
.
formatted
<<
std
::
string
(
howmany
,
'1'
);
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
std
::
string
(
howmany
,
'1'
));
helper
.
write
(
msg
);
helper
.
flush
();
}
...
...
tests/file_log.cpp
View file @
81fa788b
...
...
@@ -85,8 +85,9 @@ TEST_CASE("daily_logger", "[daily_logger]]")
// calculate filename (time based)
std
::
string
basename
=
"logs/daily_log"
;
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
fmt
::
MemoryWriter
w
;
w
.
write
(
"{}_{:04d}-{:02d}-{:02d}_{:02d}-{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
);
fmt
::
memory_buffer
w
;
fmt
::
format_to
(
w
,
"{}_{:04d}-{:02d}-{:02d}_{:02d}-{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
);
auto
logger
=
spdlog
::
daily_logger_mt
(
"logger"
,
basename
,
0
,
0
);
logger
->
flush_on
(
spdlog
::
level
::
info
);
...
...
@@ -95,7 +96,7 @@ TEST_CASE("daily_logger", "[daily_logger]]")
logger
->
info
(
"Test message {}"
,
i
);
}
auto
filename
=
w
.
str
(
);
auto
filename
=
fmt
::
to_string
(
w
);
REQUIRE
(
count_lines
(
filename
)
==
10
);
}
...
...
@@ -107,8 +108,8 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger_dateonly]]")
// calculate filename (time based)
std
::
string
basename
=
"logs/daily_dateonly"
;
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
fmt
::
MemoryWrit
er
w
;
w
.
write
(
"{}_{:04d}-{:02d}-{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
fmt
::
memory_buff
er
w
;
fmt
::
format_to
(
w
,
"{}_{: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
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
...
...
@@ -117,7 +118,7 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger_dateonly]]")
logger
->
info
(
"Test message {}"
,
i
);
}
logger
->
flush
();
auto
filename
=
w
.
str
(
);
auto
filename
=
fmt
::
to_string
(
w
);
REQUIRE
(
count_lines
(
filename
)
==
10
);
}
...
...
@@ -126,9 +127,9 @@ struct custom_daily_file_name_calculator
static
spdlog
::
filename_t
calc_filename
(
const
spdlog
::
filename_t
&
basename
)
{
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
fmt
::
MemoryWrit
er
w
;
w
.
write
(
"{}{:04d}{:02d}{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
return
w
.
str
(
);
fmt
::
memory_buff
er
w
;
fmt
::
format_to
(
w
,
"{}{:04d}{:02d}{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
return
fmt
::
to_string
(
w
);
}
};
...
...
@@ -140,8 +141,8 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger_custom]]")
// calculate filename (time based)
std
::
string
basename
=
"logs/daily_dateonly"
;
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
fmt
::
MemoryWrit
er
w
;
w
.
write
(
"{}{:04d}{:02d}{:02d}"
,
basename
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
);
fmt
::
memory_buff
er
w
;
fmt
::
format_to
(
w
,
"{}{: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
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
...
...
@@ -150,7 +151,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger_custom]]")
}
logger
->
flush
();
auto
filename
=
w
.
str
(
);
auto
filename
=
fmt
::
to_string
(
w
);
REQUIRE
(
count_lines
(
filename
)
==
10
);
}
...
...
tests/test_pattern_formatter.cpp
View file @
81fa788b
...
...
@@ -68,7 +68,7 @@ TEST_CASE("color range test1", "[pattern_formatter]")
{
auto
formatter
=
std
::
make_shared
<
spdlog
::
pattern_formatter
>
(
"%^%v%$"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
);
spdlog
::
details
::
log_msg
msg
;
msg
.
raw
<<
"Hello"
;
fmt
::
format_to
(
msg
.
raw
,
"Hello"
)
;
formatter
->
format
(
msg
);
REQUIRE
(
msg
.
color_range_start
==
0
);
REQUIRE
(
msg
.
color_range_end
==
5
);
...
...
@@ -98,7 +98,7 @@ TEST_CASE("color range test4", "[pattern_formatter]")
{
auto
formatter
=
std
::
make_shared
<
spdlog
::
pattern_formatter
>
(
"XX%^YYY%$"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
);
spdlog
::
details
::
log_msg
msg
;
msg
.
raw
<<
"ignored"
;
fmt
::
format_to
(
msg
.
raw
,
"ignored"
)
;
formatter
->
format
(
msg
);
REQUIRE
(
msg
.
color_range_start
==
2
);
REQUIRE
(
msg
.
color_range_end
==
5
);
...
...
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