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
15916566
Commit
15916566
authored
Dec 07, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed example
parent
76436d07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
example/Makefile
example/Makefile
+1
-1
example/example.cpp
example/example.cpp
+14
-6
No files found.
example/Makefile
View file @
15916566
...
...
@@ -4,7 +4,7 @@ CXX_RELEASE_FLAGS = -O3 -flto
CXX_DEBUG_FLAGS
=
-g
all
:
bench
all
:
example
bench
debug
:
example-debug bench-debug
example
:
example.cpp
...
...
example/example.cpp
View file @
15916566
...
...
@@ -26,8 +26,8 @@
// spdlog usage example
//
#include <iostream>
#include "spdlog/spdlog.h"
#include "spdlog/details/format.h"
#include "spdlog/spdlog.h"
ls
int
main
(
int
,
char
*
[])
{
...
...
@@ -36,8 +36,6 @@ int main(int, char* [])
try
{
fmt
::
print
(
"Hello man {} {:1f}
\n
"
,
1
,
2.2
);
return
0
;
std
::
string
filename
=
"logs/spdlog_example"
;
// Set log level to all loggers to DEBUG and above
spd
::
set_level
(
spd
::
level
::
DEBUG
);
...
...
@@ -46,9 +44,19 @@ int main(int, char* [])
//Create console, multithreaded logger
auto
console
=
spd
::
stdout_logger_mt
(
"console"
);
console
->
info
(
"Welcome to spdlog!"
)
;
console
->
info
(
"An info message example
"
,
"..."
,
1
,
2
,
3.5
);
console
->
info
(
"An info message example
{}.."
,
1
);
console
->
info
()
<<
"Streams are supported too "
<<
1
;
console
->
info
(
"Easy padding in numbers like {:08d}"
,
12
);
console
->
info
(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}"
,
42
);
console
->
info
(
"Support for floats {:03.2f}"
,
1.23456
);
console
->
info
(
"Positional args are {1} {0}.."
,
"too"
,
"supported"
);
console
->
info
(
"{:<30}"
,
"left aligned"
);
console
->
info
(
"{:>30}"
,
"right aligned"
);
console
->
info
(
"{:^30}"
,
"centered"
);
//Create a file rotating logger with 5mb size max and 3 rotated files
auto
file_logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
filename
,
1024
*
1024
*
5
,
3
);
file_logger
->
info
(
"Log file message number"
,
1
);
...
...
@@ -65,7 +73,7 @@ int main(int, char* [])
// Asynchronous logging is easy..
// Just call spdlog::set_async_mode(max_q_size) and all created loggers from now on will be asynchronous..
//
size_t
max_q_size
=
10
0000
;
size_t
max_q_size
=
10
48576
;
spdlog
::
set_async_mode
(
max_q_size
);
auto
async_file
=
spd
::
daily_logger_st
(
"async_file_logger"
,
"logs/async_log.txt"
);
async_file
->
info
()
<<
"This is async log.."
<<
"Should be very fast!"
;
...
...
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