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
9e3656a1
Commit
9e3656a1
authored
Nov 07, 2014
by
gabi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/gabime/spdlog
parents
4fb55903
a8c80c40
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
43 deletions
+43
-43
README.md
README.md
+1
-1
boost-bench-mt.cpp
bench/boost-bench-mt.cpp
+14
-14
boost-bench.cpp
bench/boost-bench.cpp
+4
-4
spdlog-bench-mt.cpp
bench/spdlog-bench-mt.cpp
+16
-16
spdlog-bench.cpp
bench/spdlog-bench.cpp
+6
-6
example.cpp
example/example.cpp
+1
-1
pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+1
-1
No files found.
README.md
View file @
9e3656a1
...
@@ -28,7 +28,7 @@ Just copy the files to your build tree and use a C++11 compiler
...
@@ -28,7 +28,7 @@ Just copy the files to your build tree and use a C++11 compiler
## Benchmarks
## Benchmarks
Here are some
[
benchmarks
](
bench
-comparison
)
comparing spdlog vs boost log(1.56.0) on Ubuntu 64 bits, Intel i7-4770 CPU @ 3.40GHz.
Here are some
[
benchmarks
](
bench
)
comparing spdlog vs boost log(1.56.0) on Ubuntu 64 bits, Intel i7-4770 CPU @ 3.40GHz.
The bench writes 1,000,000 log lines to a rotating log file (using shared synchronous logger object):
The bench writes 1,000,000 log lines to a rotating log file (using shared synchronous logger object):
...
...
bench/boost-bench-mt.cpp
View file @
9e3656a1
...
@@ -23,7 +23,7 @@ void init()
...
@@ -23,7 +23,7 @@ void init()
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
auto_flush
=
false
,
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
);
logging
::
core
::
get
()
->
set_filter
logging
::
core
::
get
()
->
set_filter
...
@@ -38,24 +38,24 @@ using namespace std;
...
@@ -38,24 +38,24 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
thread_count
=
10
;
int
thread_count
=
10
;
if
(
argc
>
1
)
if
(
argc
>
1
)
thread_count
=
atoi
(
argv
[
1
]);
thread_count
=
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
int
howmany
=
1000000
;
init
();
init
();
logging
::
add_common_attributes
();
logging
::
add_common_attributes
();
using
namespace
logging
::
trivial
;
using
namespace
logging
::
trivial
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
vector
<
thread
>
threads
;
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
{
threads
.
push_back
(
std
::
thread
([
&
]()
threads
.
push_back
(
std
::
thread
([
&
]()
...
@@ -64,7 +64,7 @@ int main(int argc, char* argv[])
...
@@ -64,7 +64,7 @@ int main(int argc, char* argv[])
{
{
int
counter
=
++
msg_counter
;
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
if
(
counter
>
howmany
)
break
;
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
counter
;
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
counter
;
}
}
}));
}));
}
}
...
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
...
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
{
{
t
.
join
();
t
.
join
();
};
};
return
0
;
return
0
;
}
}
bench/boost-bench.cpp
View file @
9e3656a1
...
@@ -20,7 +20,7 @@ void init()
...
@@ -20,7 +20,7 @@ void init()
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
auto_flush
=
false
,
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
);
logging
::
core
::
get
()
->
set_filter
logging
::
core
::
get
()
->
set_filter
...
@@ -32,14 +32,14 @@ void init()
...
@@ -32,14 +32,14 @@ void init()
int
main
(
int
argc
,
char
*
[])
int
main
(
int
argc
,
char
*
[])
{
{
int
howmany
=
1000000
;
int
howmany
=
1000000
;
init
();
init
();
logging
::
add_common_attributes
();
logging
::
add_common_attributes
();
using
namespace
logging
::
trivial
;
using
namespace
logging
::
trivial
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
i
;
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
i
;
return
0
;
return
0
;
}
}
bench/spdlog-bench-mt.cpp
View file @
9e3656a1
...
@@ -6,26 +6,26 @@
...
@@ -6,26 +6,26 @@
#include <iostream>
#include <iostream>
using
namespace
std
;
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
thread_count
=
10
;
int
thread_count
=
10
;
if
(
argc
>
1
)
if
(
argc
>
1
)
thread_count
=
atoi
(
argv
[
1
]);
thread_count
=
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
int
howmany
=
1000000
;
namespace
spd
=
spdlog
;
namespace
spd
=
spdlog
;
///Create a file rotating logger with 5mb size max and 3 rotated files
///Create a file rotating logger with 5mb size max and 3 rotated files
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
*
1024
*
1024
,
5
);
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
*
1024
*
1024
,
5
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
vector
<
thread
>
threads
;
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
{
threads
.
push_back
(
std
::
thread
([
&
]()
threads
.
push_back
(
std
::
thread
([
&
]()
{
{
...
@@ -33,7 +33,7 @@ int main(int argc, char* argv[])
...
@@ -33,7 +33,7 @@ int main(int argc, char* argv[])
{
{
int
counter
=
++
msg_counter
;
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
if
(
counter
>
howmany
)
break
;
logger
->
info
()
<<
"spdlog logger message #"
<<
counter
;
logger
->
info
()
<<
"spdlog logger message #"
<<
counter
;
}
}
}));
}));
}
}
...
@@ -43,8 +43,8 @@ int main(int argc, char* argv[])
...
@@ -43,8 +43,8 @@ int main(int argc, char* argv[])
{
{
t
.
join
();
t
.
join
();
};
};
return
0
;
return
0
;
}
}
bench/spdlog-bench.cpp
View file @
9e3656a1
...
@@ -4,14 +4,14 @@
...
@@ -4,14 +4,14 @@
int
main
(
int
argc
,
char
*
[])
int
main
(
int
argc
,
char
*
[])
{
{
int
howmany
=
1000000
;
int
howmany
=
1000000
;
namespace
spd
=
spdlog
;
namespace
spd
=
spdlog
;
///Create a file rotating logger with 5mb size max and 3 rotated files
///Create a file rotating logger with 5mb size max and 3 rotated files
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
*
1024
*
1024
,
5
);
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
*
1024
*
1024
,
5
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
logger
->
info
()
<<
"spdlogger message #"
<<
i
;
logger
->
info
()
<<
"spdlogger message #"
<<
i
;
return
0
;
return
0
;
}
}
example/example.cpp
View file @
9e3656a1
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "spdlog/spdlog.h"
#include "spdlog/spdlog.h"
int
main
a
(
int
,
char
*
[])
int
main
(
int
,
char
*
[])
{
{
namespace
spd
=
spdlog
;
namespace
spd
=
spdlog
;
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
9e3656a1
...
@@ -457,7 +457,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
...
@@ -457,7 +457,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
{
{
switch
(
flag
)
switch
(
flag
)
{
{
// logger name
// logger name
case
'n'
:
case
'n'
:
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
name_formatter
()));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
name_formatter
()));
break
;
break
;
...
...
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