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
5650f10b
Commit
5650f10b
authored
Jul 03, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEPRECATED: operator<< API
parent
70d0e873
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
32 additions
and
62 deletions
+32
-62
README.md
README.md
+2
-13
spdlog-async.cpp
bench/spdlog-async.cpp
+1
-1
spdlog-bench-mt.cpp
bench/spdlog-bench-mt.cpp
+1
-1
spdlog-bench.cpp
bench/spdlog-bench.cpp
+1
-1
example.cpp
example/example.cpp
+1
-15
common.h
include/spdlog/common.h
+8
-0
line_logger_fwd.h
include/spdlog/details/line_logger_fwd.h
+13
-13
logger_impl.h
include/spdlog/details/logger_impl.h
+1
-1
format.cpp
tests/format.cpp
+2
-15
tests.vcxproj
tests/tests.vcxproj
+2
-2
No files found.
README.md
View file @
5650f10b
...
...
@@ -68,8 +68,7 @@ int main(int, char* [])
// console logger (multithreaded and with color)
auto
console
=
spd
::
stdout_logger_mt
(
"console"
,
true
);
console
->
info
(
"Welcome to spdlog!"
)
;
console
->
info
(
"An info message example {}.."
,
1
);
console
->
info
()
<<
"Streams are supported too "
<<
1
;
console
->
info
(
"An info message example {}.."
,
1
);
//Formatting examples
console
->
info
(
"Easy padding in numbers like {:08d}"
,
12
);
...
...
@@ -129,7 +128,7 @@ int main(int, char* [])
size_t
q_size
=
8192
;
//queue size must be power of 2
spdlog
::
set_async_mode
(
q_size
);
auto
async_file
=
spd
::
daily_logger_st
(
"async_file_logger"
,
"logs/async_log.txt"
);
async_file
->
info
(
)
<<
"This is async log.."
<<
"Should be very fast!"
;
async_file
->
info
(
"This is async log..Should be very fast!"
)
;
//
// syslog example. linux only..
...
...
@@ -148,16 +147,6 @@ int main(int, char* [])
}
// Example of user defined class with operator<<
class
some_class
{};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
some_class
&
c
)
{
return
os
<<
"some_class"
;
}
void
custom_class_example
()
{
some_class
c
;
spdlog
::
get
(
"console"
)
->
info
(
"custom class with operator<<: {}.."
,
c
);
spdlog
::
get
(
"console"
)
->
info
()
<<
"custom class with operator<<: "
<<
c
<<
".."
;
}
```
## Documentation
...
...
bench/spdlog-async.cpp
View file @
5650f10b
...
...
@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
{
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
logger
->
info
(
)
<<
"spdlog message #"
<<
counter
<<
": This is some text for your pleasure"
;
logger
->
info
(
"spdlog message #{}: This is some text for your pleasure"
,
counter
)
;
}
}));
}
...
...
bench/spdlog-bench-mt.cpp
View file @
5650f10b
...
...
@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
{
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
logger
->
info
(
)
<<
"spdlog message #"
<<
counter
<<
": This is some text for your pleasure"
;
logger
->
info
(
"spdlog message #{}: This is some text for your pleasure"
,
counter
)
;
}
}));
}
...
...
bench/spdlog-bench.cpp
View file @
5650f10b
...
...
@@ -15,6 +15,6 @@ int main(int, char* [])
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
logger
->
info
(
)
<<
"spdlog message #"
<<
i
<<
": This is some text for your pleasure"
;
logger
->
info
(
"spdlog message #{} : This is some text for your pleasure"
,
i
)
;
return
0
;
}
example/example.cpp
View file @
5650f10b
...
...
@@ -23,7 +23,6 @@ int main(int, char*[])
auto
console
=
spd
::
stdout_logger_mt
(
"console"
,
true
);
console
->
info
(
"Welcome to spdlog!"
);
console
->
info
(
"An info message example {}.."
,
1
);
console
->
info
()
<<
"Streams are supported too "
<<
1
;
// Formatting examples
console
->
info
(
"Easy padding in numbers like {:08d}"
,
12
);
...
...
@@ -55,6 +54,7 @@ int main(int, char*[])
// Create a daily logger - a new file is created every day on 2:30am
auto
daily_logger
=
spd
::
daily_logger_mt
(
"daily_logger"
,
"logs/daily"
,
2
,
30
);
daily_logger
->
info
(
123.44
);
// Customize msg format for all messages
spd
::
set_pattern
(
"*** [%H:%M:%S %z] [thread %t] %v ***"
);
...
...
@@ -107,17 +107,3 @@ void syslog_example()
}
// Example of user defined class with operator<<
class
some_class
{};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
some_class
&
)
{
return
os
<<
"some_class"
;
}
void
custom_class_example
()
{
some_class
c
;
spdlog
::
get
(
"console"
)
->
info
(
"custom class with operator<<: {}.."
,
c
);
spdlog
::
get
(
"console"
)
->
info
()
<<
"custom class with operator<<: "
<<
c
<<
".."
;
}
include/spdlog/common.h
View file @
5650f10b
...
...
@@ -27,6 +27,14 @@
#define SPDLOG_CONSTEXPR constexpr
#endif
#if defined(__GNUC__) || defined(__clang__)
#define DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#else
#pragma message("DEPRECATED")
#define DEPRECATED
#endif
namespace
spdlog
{
...
...
include/spdlog/details/line_logger_fwd.h
View file @
5650f10b
...
...
@@ -49,21 +49,21 @@ public:
//
// Support for operator<<
//
line_logger
&
operator
<<
(
const
char
*
what
);
line_logger
&
operator
<<
(
const
std
::
string
&
what
);
line_logger
&
operator
<<
(
int
what
);
line_logger
&
operator
<<
(
unsigned
int
what
);
line_logger
&
operator
<<
(
long
what
);
line_logger
&
operator
<<
(
unsigned
long
what
);
line_logger
&
operator
<<
(
long
long
what
);
line_logger
&
operator
<<
(
unsigned
long
long
what
);
line_logger
&
operator
<<
(
double
what
);
line_logger
&
operator
<<
(
long
double
what
);
line_logger
&
operator
<<
(
float
what
);
line_logger
&
operator
<<
(
char
what
);
DEPRECATED
line_logger
&
operator
<<
(
const
char
*
what
);
DEPRECATED
line_logger
&
operator
<<
(
const
std
::
string
&
what
);
DEPRECATED
line_logger
&
operator
<<
(
int
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
int
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
long
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
double
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
double
what
);
DEPRECATED
line_logger
&
operator
<<
(
float
what
);
DEPRECATED
line_logger
&
operator
<<
(
char
what
);
//Support user types which implements operator<<
template
<
typename
T
>
line_logger
&
operator
<<
(
const
T
&
what
);
DEPRECATED
line_logger
&
operator
<<
(
const
T
&
what
);
void
disable
();
bool
is_enabled
()
const
;
...
...
include/spdlog/details/logger_impl.h
View file @
5650f10b
...
...
@@ -74,7 +74,7 @@ inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level
{
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
l
<<
msg
;
l
.
write
(
"{}"
,
msg
)
;
return
l
;
}
...
...
tests/format.cpp
View file @
5650f10b
...
...
@@ -11,7 +11,7 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
spdlog
::
logger
oss_logger
(
"oss"
,
oss_sink
);
oss_logger
.
set_level
(
logger_level
);
oss_logger
.
set_pattern
(
"%v"
);
oss_logger
.
info
(
)
<<
what
;
oss_logger
.
info
(
what
)
;
return
oss
.
str
().
substr
(
0
,
oss
.
str
().
length
()
-
spdlog
::
details
::
os
::
eol_size
);
}
...
...
@@ -21,19 +21,6 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
//User defined class with operator<<
struct
some_logged_class
{
some_logged_class
(
const
std
::
string
val
)
:
value
(
val
)
{};
std
::
string
value
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
some_logged_class
&
c
)
{
return
os
<<
c
.
value
;
}
TEST_CASE
(
"basic_logging "
,
"[basic_logging]"
)
{
//const char
...
...
@@ -49,7 +36,7 @@ TEST_CASE("basic_logging ", "[basic_logging]")
REQUIRE
(
log_info
(
5.6
)
==
"5.6"
);
//User defined class
REQUIRE
(
log_info
(
some_logged_class
(
"some_val"
))
==
"some_val"
);
//
REQUIRE(log_info(some_logged_class("some_val")) == "some_val");
}
...
...
tests/tests.vcxproj
View file @
5650f10b
...
...
@@ -26,7 +26,7 @@
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v1
4
0
</PlatformToolset>
<PlatformToolset>
v1
2
0
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
...
...
@@ -38,7 +38,7 @@
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v1
4
0
</PlatformToolset>
<PlatformToolset>
v1
2
0
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
...
...
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