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
4fd1ac8a
Commit
4fd1ac8a
authored
Jan 05, 2015
by
gabi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for logger->info(const T&) call style
parent
03735e22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
32 deletions
+96
-32
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+68
-4
include/spdlog/logger.h
include/spdlog/logger.h
+28
-28
No files found.
include/spdlog/details/logger_impl.h
View file @
4fd1ac8a
...
@@ -85,9 +85,17 @@ inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level
...
@@ -85,9 +85,17 @@ inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level
return
details
::
line_logger
(
this
,
lvl
,
should_log
(
lvl
));
return
details
::
line_logger
(
this
,
lvl
,
should_log
(
lvl
));
}
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
_log_if_enabled
(
level
::
level_enum
lvl
,
const
T
&
msg
)
{
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
l
<<
msg
;
return
l
;
}
//
//
//
following functions will log only if at the right level
//
logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
//
//
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
(
const
char
*
fmt
,
const
Args
&
...
args
)
...
@@ -143,19 +151,75 @@ inline spdlog::details::line_logger spdlog::logger::emerg(const char* fmt, const
...
@@ -143,19 +151,75 @@ inline spdlog::details::line_logger spdlog::logger::emerg(const char* fmt, const
return
_log_if_enabled
(
level
::
emerg
,
fmt
,
args
...);
return
_log_if_enabled
(
level
::
emerg
,
fmt
,
args
...);
}
}
//
//
//
support logger.info() << ".." calls
//
logger.info(msg) << ".." call style
//
//
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
trace
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
debug
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
info
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
info
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
notice
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
notice
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
warn
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
warn
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
error
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
err
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
critical
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
critical
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
alert
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
alert
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
emerg
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
emerg
,
msg
);
}
//
// logger.info() << ".." call style
//
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
()
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
()
{
{
return
_log_if_enabled
(
level
::
trace
);
return
_log_if_enabled
(
level
::
trace
);
}
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
()
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
()
{
{
return
_log_if_enabled
(
level
::
debug
);
return
_log_if_enabled
(
level
::
debug
);
...
...
include/spdlog/logger.h
View file @
4fd1ac8a
...
@@ -62,34 +62,31 @@ public:
...
@@ -62,34 +62,31 @@ public:
const
std
::
string
&
name
()
const
;
const
std
::
string
&
name
()
const
;
bool
should_log
(
level
::
level_enum
)
const
;
bool
should_log
(
level
::
level_enum
)
const
;
template
<
typename
...
Args
>
// logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
details
::
line_logger
trace
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
trace
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
debug
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
template
<
typename
...
Args
>
details
::
line_logger
info
(
const
char
*
fmt
,
const
Args
&
...
args
);
details
::
line_logger
debug
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
notice
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
warn
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
template
<
typename
...
Args
>
details
::
line_logger
error
(
const
char
*
fmt
,
const
Args
&
...
args
);
details
::
line_logger
info
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
alert
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
template
<
typename
...
Args
>
details
::
line_logger
emerg
(
const
char
*
fmt
,
const
Args
&
...
args
);
details
::
line_logger
notice
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
// logger.info(msg) << ".." call style
details
::
line_logger
warn
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
details
::
line_logger
trace
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
debug
(
const
T
&
);
template
<
typename
...
Args
>
details
::
line_logger
error
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
details
::
line_logger
info
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
notice
(
const
T
&
);
template
<
typename
...
Args
>
template
<
typename
T
>
details
::
line_logger
warn
(
const
T
&
);
details
::
line_logger
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
details
::
line_logger
error
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
critical
(
const
T
&
);
template
<
typename
...
Args
>
template
<
typename
T
>
details
::
line_logger
alert
(
const
T
&
);
details
::
line_logger
alert
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
details
::
line_logger
emerg
(
const
T
&
);
template
<
typename
...
Args
>
details
::
line_logger
emerg
(
const
char
*
fmt
,
const
Args
&
...
args
);
// logger.info() << ".." call style
//API to support logger.info() << ".." call style
details
::
line_logger
trace
();
details
::
line_logger
trace
();
details
::
line_logger
debug
();
details
::
line_logger
debug
();
details
::
line_logger
info
();
details
::
line_logger
info
();
...
@@ -101,6 +98,7 @@ public:
...
@@ -101,6 +98,7 @@ public:
details
::
line_logger
emerg
();
details
::
line_logger
emerg
();
// Create log message with the given level, no matter what is the actual logger's level
// Create log message with the given level, no matter what is the actual logger's level
template
<
typename
...
Args
>
template
<
typename
...
Args
>
details
::
line_logger
force_log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
details
::
line_logger
force_log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
...
@@ -117,6 +115,8 @@ protected:
...
@@ -117,6 +115,8 @@ protected:
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
);
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
);
template
<
typename
...
Args
>
template
<
typename
...
Args
>
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
inline
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
,
const
T
&
msg
);
friend
details
::
line_logger
;
friend
details
::
line_logger
;
...
...
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