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
5550eb97
Commit
5550eb97
authored
May 04, 2016
by
Gabi Melman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #202 from godbyk/autoflush
Automatically flush log if message level is above certain severity.
parents
292bdc5e
d9ff5df8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+10
-0
include/spdlog/logger.h
include/spdlog/logger.h
+4
-0
No files found.
include/spdlog/details/logger_impl.h
View file @
5550eb97
...
...
@@ -21,6 +21,7 @@ inline spdlog::logger::logger(const std::string& logger_name, const It& begin, c
// no support under vs2013 for member initialization for std::atomic
_level
=
level
::
info
;
_flush_level
=
level
::
off
;
}
// ctor with sinks as init list
...
...
@@ -266,6 +267,11 @@ inline void spdlog::logger::set_level(spdlog::level::level_enum log_level)
_level
.
store
(
log_level
);
}
inline
void
spdlog
::
logger
::
flush_on
(
level
::
level_enum
log_level
)
{
_flush_level
.
store
(
log_level
);
}
inline
spdlog
::
level
::
level_enum
spdlog
::
logger
::
level
()
const
{
return
static_cast
<
spdlog
::
level
::
level_enum
>
(
_level
.
load
(
std
::
memory_order_relaxed
));
...
...
@@ -284,6 +290,10 @@ inline void spdlog::logger::_log_msg(details::log_msg& msg)
_formatter
->
format
(
msg
);
for
(
auto
&
sink
:
_sinks
)
sink
->
log
(
msg
);
const
auto
flush_level
=
_flush_level
.
load
(
std
::
memory_order_relaxed
);
if
(
msg
.
level
>=
flush_level
)
flush
();
}
inline
void
spdlog
::
logger
::
_set_pattern
(
const
std
::
string
&
pattern
)
...
...
include/spdlog/logger.h
View file @
5550eb97
...
...
@@ -41,6 +41,9 @@ public:
const
std
::
string
&
name
()
const
;
bool
should_log
(
level
::
level_enum
)
const
;
// automatically call flush() after a message of level log_level or higher is emitted
void
flush_on
(
level
::
level_enum
log_level
);
// logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
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
);
...
...
@@ -104,6 +107,7 @@ protected:
std
::
vector
<
sink_ptr
>
_sinks
;
formatter_ptr
_formatter
;
spdlog
::
level_t
_level
;
spdlog
::
level_t
_flush_level
;
};
}
...
...
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