Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
8387d779
Commit
8387d779
authored
May 15, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed tests
parent
c701420c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
Makefile
tests/Makefile
+1
-1
file_log.cpp
tests/file_log.cpp
+3
-7
format.cpp
tests/format.cpp
+6
-3
No files found.
tests/Makefile
View file @
8387d779
CXX
?=
g++
CXX
?=
g++
CXXFLAGS
=
-
D_WIN32_WINNT
=
0x600
-march
=
native
-Wall
-pedantic
-std
=
c++11
-pthread
-Wl
,--no-as-needed
-O
CXXFLAGS
=
-
Wall
-pedantic
-std
=
c++11
-pthread
-Wl
,--no-as-needed
-O2
LDPFALGS
=
-pthread
-flto
LDPFALGS
=
-pthread
-flto
CPP_FILES
:=
$
(
wildcard
*
.cpp
)
CPP_FILES
:=
$
(
wildcard
*
.cpp
)
...
...
tests/file_log.cpp
View file @
8387d779
...
@@ -10,7 +10,6 @@ static std::string file_contents(const std::string& filename)
...
@@ -10,7 +10,6 @@ static std::string file_contents(const std::string& filename)
}
}
static
std
::
size_t
count_lines
(
const
std
::
string
&
filename
)
static
std
::
size_t
count_lines
(
const
std
::
string
&
filename
)
{
{
std
::
ifstream
ifs
(
filename
);
std
::
ifstream
ifs
(
filename
);
...
@@ -51,12 +50,9 @@ TEST_CASE("simple_file_logger", "[simple_logger]]")
...
@@ -51,12 +50,9 @@ TEST_CASE("simple_file_logger", "[simple_logger]]")
std
::
string
filename
=
"logs/simple_log.txt"
;
std
::
string
filename
=
"logs/simple_log.txt"
;
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"logger"
,
filename
);
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"logger"
,
filename
);
REQUIRE_THROWS_AS
(
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"logger2"
,
filename
);
,
spdlog
::
spdlog_ex
);
logger
->
set_pattern
(
"%v"
);
logger
->
set_pattern
(
"%v"
);
logger
->
info
(
"Test message {}"
,
1
);
logger
->
info
(
"Test message {}"
,
1
);
logger
->
info
(
"Test message {}"
,
2
);
logger
->
info
(
"Test message {}"
,
2
);
logger
->
flush
();
logger
->
flush
();
...
@@ -107,7 +103,7 @@ TEST_CASE("daily_logger", "[daily_logger]]")
...
@@ -107,7 +103,7 @@ TEST_CASE("daily_logger", "[daily_logger]]")
{
{
delete_logs
();
delete_logs
();
//calculate filename (time based)
//calculate filename (time based)
std
::
string
basename
=
"logs/daily_log"
;
std
::
string
basename
=
"logs/daily_log"
;
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
fmt
::
MemoryWriter
w
;
fmt
::
MemoryWriter
w
;
...
...
tests/format.cpp
View file @
8387d779
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
#include "includes.h"
#include "includes.h"
template
<
class
T
>
template
<
class
T
>
std
::
string
log_info
(
const
T
&
what
,
spdlog
::
level
::
level_enum
logger_level
=
spdlog
::
level
::
info
)
{
std
::
string
log_info
(
const
T
&
what
,
spdlog
::
level
::
level_enum
logger_level
=
spdlog
::
level
::
info
)
{
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
auto
oss_sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ostream_sink_mt
>
(
oss
);
auto
oss_sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ostream_sink_mt
>
(
oss
);
...
@@ -28,13 +29,15 @@ struct some_logged_class
...
@@ -28,13 +29,15 @@ struct some_logged_class
some_logged_class
(
const
std
::
string
val
)
:
value
(
val
)
{};
some_logged_class
(
const
std
::
string
val
)
:
value
(
val
)
{};
std
::
string
value
;
std
::
string
value
;
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
some_logged_class
&
c
)
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
some_logged_class
&
c
)
{
return
os
<<
c
.
value
;
return
os
<<
c
.
value
;
}
}
TEST_CASE
(
"basic_logging "
,
"[basic_logging]"
)
{
TEST_CASE
(
"basic_logging "
,
"[basic_logging]"
)
{
//const char
//const char
REQUIRE
(
log_info
(
"Hello"
)
==
"Hello"
);
REQUIRE
(
log_info
(
"Hello"
)
==
"Hello"
);
REQUIRE
(
log_info
(
""
)
==
""
);
REQUIRE
(
log_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