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
05d6960e
Commit
05d6960e
authored
Aug 13, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code formatting and clang tidy warnings fixes
parent
4866f2ac
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
29 additions
and
34 deletions
+29
-34
README.md
README.md
+1
-1
async.h
include/spdlog/async.h
+1
-1
async_logger.h
include/spdlog/async_logger.h
+1
-1
common.h
include/spdlog/common.h
+2
-2
async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+1
-1
console_globals.h
include/spdlog/details/console_globals.h
+3
-3
pattern_formatter.h
include/spdlog/details/pattern_formatter.h
+2
-3
periodic_worker.h
include/spdlog/details/periodic_worker.h
+1
-1
registry.h
include/spdlog/details/registry.h
+4
-8
thread_pool.h
include/spdlog/details/thread_pool.h
+1
-1
base_sink.h
include/spdlog/sinks/base_sink.h
+1
-1
sink.h
include/spdlog/sinks/sink.h
+1
-1
stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+4
-4
syslog_sink.h
include/spdlog/sinks/syslog_sink.h
+2
-2
spdlog.h
include/spdlog/spdlog.h
+3
-3
file_log.cpp
tests/file_log.cpp
+1
-1
No files found.
README.md
View file @
05d6960e
...
...
@@ -28,7 +28,7 @@ Very fast, header only, C++ logging library. [![Build Status](https://travis-ci.
## Features
*
Very fast - performance is the primary goal (see
[
benchmarks
](
#benchmarks
)
below).
*
Headers only, just copy and use.
*
Feature rich
[
call style
](
#usage-example
)
using the excellent
[
fmt
](
https://github.com/fmtlib/fmt
)
library.
*
Feature rich using the excellent
[
fmt
](
https://github.com/fmtlib/fmt
)
library.
*
Fast asynchronous mode (optional)
*
[
Custom
](
https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
)
formatting.
*
Conditional Logging
...
...
include/spdlog/async.h
View file @
05d6960e
...
...
@@ -42,7 +42,7 @@ struct async_factory_impl
auto
&
registry_inst
=
details
::
registry
::
instance
();
// create global thread pool if not already exists..
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
registry_inst
.
tp_mutex
());
std
::
lock_guard
<
std
::
recursive_mutex
>
tp_
lock
(
registry_inst
.
tp_mutex
());
auto
tp
=
registry_inst
.
get_tp
();
if
(
tp
==
nullptr
)
{
...
...
include/spdlog/async_logger.h
View file @
05d6960e
...
...
@@ -49,7 +49,7 @@ public:
async_logger
(
std
::
string
logger_name
,
const
It
&
begin
,
const
It
&
end
,
std
::
weak_ptr
<
details
::
thread_pool
>
tp
,
async_overflow_policy
overflow_policy
=
async_overflow_policy
::
block
);
async_logger
(
std
::
string
logger_name
,
sinks_init_list
sinks
,
std
::
weak_ptr
<
details
::
thread_pool
>
tp
,
async_logger
(
std
::
string
logger_name
,
sinks_init_list
sinks
_list
,
std
::
weak_ptr
<
details
::
thread_pool
>
tp
,
async_overflow_policy
overflow_policy
=
async_overflow_policy
::
block
);
async_logger
(
std
::
string
logger_name
,
sink_ptr
single_sink
,
std
::
weak_ptr
<
details
::
thread_pool
>
tp
,
...
...
include/spdlog/common.h
View file @
05d6960e
...
...
@@ -138,8 +138,8 @@ public:
:
runtime_error
(
msg
)
{
}
spdlog_ex
(
std
::
string
msg
,
int
last_errno
)
:
runtime_error
(
std
::
move
(
msg
)
)
spdlog_ex
(
const
std
::
string
&
msg
,
int
last_errno
)
:
runtime_error
(
msg
)
,
last_errno_
(
last_errno
)
{
}
...
...
include/spdlog/details/async_logger_impl.h
View file @
05d6960e
...
...
@@ -47,7 +47,7 @@ inline void spdlog::async_logger::sink_it_(details::log_msg &msg)
}
else
{
throw
spdlog_ex
(
"async log: thread pool doe
ns
't exist anymore"
);
throw
spdlog_ex
(
"async log: thread pool doe
sn
't exist anymore"
);
}
}
...
...
include/spdlog/details/console_globals.h
View file @
05d6960e
...
...
@@ -5,14 +5,14 @@
//
#include "spdlog/details/null_mutex.h"
#include
"stdio.h"
#include
<cstdio>
#include <mutex>
namespace
spdlog
{
namespace
details
{
struct
console_stdout
{
static
FILE
*
stream
()
static
std
::
FILE
*
stream
()
{
return
stdout
;
}
...
...
@@ -26,7 +26,7 @@ struct console_stdout
struct
console_stderr
{
static
FILE
*
stream
()
static
std
::
FILE
*
stream
()
{
return
stderr
;
}
...
...
include/spdlog/details/pattern_formatter.h
View file @
05d6960e
...
...
@@ -69,7 +69,7 @@ static const char *ampm(const tm &t)
return
t
.
tm_hour
>=
12
?
"PM"
:
"AM"
;
}
static
unsigned
int
to12h
(
const
tm
&
t
)
static
int
to12h
(
const
tm
&
t
)
{
return
t
.
tm_hour
>
12
?
t
.
tm_hour
-
12
:
t
.
tm_hour
;
}
...
...
@@ -242,7 +242,7 @@ class f_formatter SPDLOG_FINAL : public flag_formatter
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
auto
micros
=
fmt_helper
::
time_fraction
<
std
::
chrono
::
microseconds
>
(
msg
.
time
);
fmt_helper
::
pad6
(
static_cast
<
in
t
>
(
micros
.
count
()),
dest
);
fmt_helper
::
pad6
(
static_cast
<
size_
t
>
(
micros
.
count
()),
dest
);
}
};
...
...
@@ -745,7 +745,6 @@ private:
{
formatters_
.
push_back
(
std
::
move
(
user_chars
));
}
// if(
if
(
++
it
!=
end
)
{
handle_flag_
(
*
it
);
...
...
include/spdlog/details/periodic_worker.h
View file @
05d6960e
...
...
@@ -23,7 +23,7 @@ namespace details {
class
periodic_worker
{
public
:
periodic_worker
(
std
::
function
<
void
()
>
callback_fun
,
std
::
chrono
::
seconds
interval
)
periodic_worker
(
const
std
::
function
<
void
()
>
&
callback_fun
,
std
::
chrono
::
seconds
interval
)
{
active_
=
(
interval
>
std
::
chrono
::
seconds
::
zero
());
if
(
!
active_
)
...
...
include/spdlog/details/registry.h
View file @
05d6960e
...
...
@@ -35,7 +35,7 @@ public:
std
::
lock_guard
<
std
::
mutex
>
lock
(
logger_map_mutex_
);
auto
logger_name
=
new_logger
->
name
();
throw_if_exists_
(
logger_name
);
loggers_
[
logger_name
]
=
new_logger
;
loggers_
[
logger_name
]
=
std
::
move
(
new_logger
)
;
}
void
register_and_init
(
std
::
shared_ptr
<
logger
>
new_logger
)
...
...
@@ -56,7 +56,7 @@ public:
new_logger
->
flush_on
(
flush_level_
);
// add to registry
loggers_
[
logger_name
]
=
new_logger
;
loggers_
[
logger_name
]
=
std
::
move
(
new_logger
)
;
}
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
logger_name
)
...
...
@@ -126,7 +126,7 @@ public:
err_handler_
=
handler
;
}
void
apply_all
(
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
fun
)
void
apply_all
(
const
std
::
function
<
void
(
const
std
::
shared_ptr
<
logger
>
)
>
&
fun
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
logger_map_mutex_
);
for
(
auto
&
l
:
loggers_
)
...
...
@@ -189,11 +189,7 @@ private:
{
}
~
registry
()
{
/*std::lock_guard<std::mutex> lock(flusher_mutex_);
periodic_flusher_.reset();*/
}
~
registry
()
=
default
;
void
throw_if_exists_
(
const
std
::
string
&
logger_name
)
{
...
...
include/spdlog/details/thread_pool.h
View file @
05d6960e
...
...
@@ -122,7 +122,7 @@ public:
}
for
(
size_t
i
=
0
;
i
<
threads_n
;
i
++
)
{
threads_
.
emplace_back
(
std
::
bind
(
&
thread_pool
::
worker_loop_
,
this
)
);
threads_
.
emplace_back
(
&
thread_pool
::
worker_loop_
,
this
);
}
}
...
...
include/spdlog/sinks/base_sink.h
View file @
05d6960e
...
...
@@ -30,7 +30,7 @@ public:
base_sink
(
const
base_sink
&
)
=
delete
;
base_sink
&
operator
=
(
const
base_sink
&
)
=
delete
;
void
log
(
const
details
::
log_msg
&
msg
)
SPDLOG_FINAL
override
void
log
(
const
details
::
log_msg
&
msg
)
SPDLOG_FINAL
{
std
::
lock_guard
<
Mutex
>
lock
(
mutex_
);
sink_it_
(
msg
);
...
...
include/spdlog/sinks/sink.h
View file @
05d6960e
...
...
@@ -20,7 +20,7 @@ public:
{
}
sink
(
std
::
unique_ptr
<
spdlog
::
pattern_formatter
>
formatter
)
explicit
sink
(
std
::
unique_ptr
<
spdlog
::
pattern_formatter
>
formatter
)
:
level_
(
level
::
trace
)
,
formatter_
(
std
::
move
(
formatter
)){};
...
...
include/spdlog/sinks/stdout_sinks.h
View file @
05d6960e
...
...
@@ -19,7 +19,7 @@ namespace spdlog {
namespace
sinks
{
template
<
typename
TargetStream
,
typename
ConsoleMutex
>
class
stdout_sink
:
public
sink
class
stdout_sink
SPDLOG_FINAL
:
public
sink
{
public
:
using
mutex_t
=
typename
ConsoleMutex
::
mutex_t
;
...
...
@@ -28,7 +28,7 @@ public:
,
file_
(
TargetStream
::
stream
())
{
}
~
stdout_sink
()
=
default
;
~
stdout_sink
()
override
=
default
;
stdout_sink
(
const
stdout_sink
&
other
)
=
delete
;
stdout_sink
&
operator
=
(
const
stdout_sink
&
other
)
=
delete
;
...
...
@@ -48,13 +48,13 @@ public:
fflush
(
file_
);
}
void
set_pattern
(
const
std
::
string
&
pattern
)
override
SPDLOG_FINAL
void
set_pattern
(
const
std
::
string
&
pattern
)
override
{
std
::
lock_guard
<
mutex_t
>
lock
(
mutex_
);
formatter_
=
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
pattern
));
}
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
sink_formatter
)
override
SPDLOG_FINAL
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
sink_formatter
)
override
{
std
::
lock_guard
<
mutex_t
>
lock
(
mutex_
);
formatter_
=
std
::
move
(
sink_formatter
);
...
...
include/spdlog/sinks/syslog_sink.h
View file @
05d6960e
...
...
@@ -24,8 +24,8 @@ class syslog_sink : public base_sink<Mutex>
{
public
:
//
syslog_sink
(
const
std
::
string
&
ident
=
""
,
int
syslog_option
=
0
,
int
syslog_facility
=
LOG_USER
)
:
ident_
(
ident
)
explicit
syslog_sink
(
std
::
string
ident
=
""
,
int
syslog_option
=
0
,
int
syslog_facility
=
LOG_USER
)
:
ident_
(
std
::
move
(
ident
)
)
{
priorities_
[
static_cast
<
size_t
>
(
level
::
trace
)]
=
LOG_DEBUG
;
priorities_
[
static_cast
<
size_t
>
(
level
::
debug
)]
=
LOG_DEBUG
;
...
...
include/spdlog/spdlog.h
View file @
05d6960e
...
...
@@ -64,7 +64,7 @@ inline void set_formatter(std::unique_ptr<spdlog::formatter> formatter)
// example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v");
inline
void
set_pattern
(
std
::
string
pattern
,
pattern_time_type
time_type
=
pattern_time_type
::
local
)
{
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
pattern
,
time_type
)));
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
std
::
move
(
pattern
)
,
time_type
)));
}
// Set global logging level
...
...
@@ -101,9 +101,9 @@ inline void register_logger(std::shared_ptr<logger> logger)
// Apply a user defined function on all registered loggers
// Example:
// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {l->flush();});
inline
void
apply_all
(
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
fun
)
inline
void
apply_all
(
const
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
&
fun
)
{
details
::
registry
::
instance
().
apply_all
(
std
::
move
(
fun
)
);
details
::
registry
::
instance
().
apply_all
(
fun
);
}
// Drop the reference to the given logger
...
...
tests/file_log.cpp
View file @
05d6960e
...
...
@@ -33,7 +33,7 @@ TEST_CASE("flush_on", "[flush_on]]")
logger
->
info
(
"Test message {}"
,
1
);
logger
->
info
(
"Test message {}"
,
2
);
REQUIRE
(
file_contents
(
filename
)
==
std
::
string
(
"Should not be flushed
\n
Test message 1
\n
Test message 2
\n
"
));
REQUIRE
(
count_lines
(
filename
)
==
3
);
}
...
...
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