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
39c6eb75
Commit
39c6eb75
authored
Jul 07, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code formatting
parent
a9a73090
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
36 deletions
+18
-36
bench.cpp
bench/bench.cpp
+3
-3
example.cpp
example/example.cpp
+1
-15
fmt_helper.h
include/spdlog/details/fmt_helper.h
+1
-1
basic_file_sink.h
include/spdlog/sinks/basic_file_sink.h
+0
-2
dist_sink.h
include/spdlog/sinks/dist_sink.h
+1
-2
sink.h
include/spdlog/sinks/sink.h
+11
-12
includes.h
tests/includes.h
+1
-1
No files found.
bench/bench.cpp
View file @
39c6eb75
...
...
@@ -7,10 +7,10 @@
// bench.cpp : spdlog benchmarks
//
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/spdlog.h"
#include "utils.h"
#include <atomic>
...
...
@@ -122,7 +122,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
for
(
int
j
=
0
;
j
<
howmany
/
thread_count
;
j
++
)
for
(
int
j
=
0
;
j
<
howmany
/
thread_count
;
j
++
)
{
log
->
info
(
"Hello logger: msg number {}"
,
j
);
}
...
...
@@ -134,7 +134,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
t
.
join
();
};
auto
delta
=
high_resolution_clock
::
now
()
-
start
;
auto
delta
=
high_resolution_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout
<<
"Elapsed: "
<<
delta_d
<<
"
\t
"
<<
format
(
int
(
howmany
/
delta_d
))
<<
"/sec"
<<
endl
;
}
example/example.cpp
View file @
39c6eb75
...
...
@@ -7,7 +7,6 @@
//
//
#include <iostream>
void
stdout_example
();
...
...
@@ -42,7 +41,6 @@ int main(int, char *[])
// custom error handler
err_handler_example
();
// apply some function on all registered loggers
spdlog
::
apply_all
([
&
](
std
::
shared_ptr
<
spdlog
::
logger
>
l
)
{
l
->
info
(
"End of example."
);
});
...
...
@@ -57,7 +55,6 @@ int main(int, char *[])
}
}
#include "spdlog/sinks/stdout_color_sinks.h" // or "/sinks/stdout_sinks.h" if no colors needed
void
stdout_example
()
...
...
@@ -68,7 +65,7 @@ void stdout_example()
console
->
error
(
"Some error message with arg: {}"
,
1
);
auto
err_logger
=
spdlog
::
stderr_color_mt
(
"error_logger"
);
err_logger
->
error
(
"Some error message"
);
err_logger
->
error
(
"Some error message"
);
// Formatting examples
console
->
warn
(
"Easy padding in numbers like {:08d}"
,
12
);
console
->
critical
(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}"
,
42
);
...
...
@@ -84,21 +81,16 @@ void stdout_example()
console
->
set_level
(
spdlog
::
level
::
trace
);
// Set specific logger's log level
console
->
debug
(
"This message should be displayed.."
);
// Customize msg format for all loggers
spdlog
::
set_pattern
(
"[%H:%M:%S %z] [%^---%L---%$] [thread %t] %v"
);
console
->
info
(
"This an info message with custom format"
);
// Compile time log levels
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
SPDLOG_TRACE
(
console
,
"Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}"
,
1
,
3.23
);
SPDLOG_DEBUG
(
console
,
"Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}"
,
1
,
3.23
);
}
#include "spdlog/sinks/basic_file_sink.h"
void
basic_example
()
{
...
...
@@ -118,10 +110,8 @@ void daily_example()
{
// Create a daily logger - a new file is created every day on 2:30am
auto
daily_logger
=
spdlog
::
daily_logger_mt
(
"daily_logger"
,
"logs/daily.txt"
,
2
,
30
);
}
#include "spdlog/async.h"
void
async_example
()
{
...
...
@@ -137,8 +127,6 @@ void async_example()
}
}
// user defined types logging by implementing operator<<
#include "spdlog/fmt/ostr.h" // must be included
struct
my_type
...
...
@@ -151,7 +139,6 @@ struct my_type
}
};
void
user_defined_example
()
{
spdlog
::
get
(
"console"
)
->
info
(
"user defined type: {}"
,
my_type
{
14
});
...
...
@@ -167,7 +154,6 @@ void err_handler_example()
spdlog
::
get
(
"console"
)
->
info
(
"some invalid message to trigger an error {}{}{}{}"
,
3
);
}
// syslog example (linux/osx/freebsd)
#ifndef _WIN32
#include "spdlog/sinks/syslog_sink.h"
...
...
include/spdlog/details/fmt_helper.h
View file @
39c6eb75
...
...
@@ -122,7 +122,7 @@ inline void pad6(size_t n, fmt::memory_buffer &dest)
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
dest
.
push_back
(
'0'
);
}
}
append_int
(
n
,
dest
);
}
...
...
include/spdlog/sinks/basic_file_sink.h
View file @
39c6eb75
...
...
@@ -26,8 +26,6 @@ public:
file_helper_
.
open
(
filename
,
truncate
);
}
protected
:
void
sink_it_
(
const
details
::
log_msg
&
,
const
fmt
::
memory_buffer
&
formatted
)
override
{
...
...
include/spdlog/sinks/dist_sink.h
View file @
39c6eb75
...
...
@@ -18,7 +18,7 @@
namespace
spdlog
{
namespace
sinks
{
template
<
typename
Mutex
>
template
<
typename
Mutex
>
class
dist_sink
:
public
sink
{
public
:
...
...
@@ -60,7 +60,6 @@ public:
private
:
Mutex
mutex_
;
std
::
vector
<
std
::
shared_ptr
<
sink
>>
sinks_
;
};
using
dist_sink_mt
=
dist_sink
<
std
::
mutex
>
;
...
...
include/spdlog/sinks/sink.h
View file @
39c6eb75
...
...
@@ -18,17 +18,17 @@ public:
:
formatter_
(
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
"%+"
)))
{
}
//
// explicit sink(const std::string &formatter_pattern)
// : formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
// {
// }
//
// // sink with custom formatter
// explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
// : formatter_(std::move(sink_formatter))
// {
// }
//
// explicit sink(const std::string &formatter_pattern)
// : formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
// {
// }
//
// // sink with custom formatter
// explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
// : formatter_(std::move(sink_formatter))
// {
// }
virtual
~
sink
()
=
default
;
...
...
@@ -60,7 +60,6 @@ public:
formatter_
=
std
::
move
(
sink_formatter
);
}
protected
:
level_t
level_
{
level
::
trace
};
std
::
unique_ptr
<
spdlog
::
formatter
>
formatter_
;
...
...
tests/includes.h
View file @
39c6eb75
...
...
@@ -13,10 +13,10 @@
#define SPDLOG_DEBUG_ON
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/ostream_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h"
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