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
11e068d7
Commit
11e068d7
authored
Apr 19, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing #include
parent
924ef842
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
9 deletions
+35
-9
example/example.cpp
example/example.cpp
+29
-8
example/example.vcxproj
example/example.vcxproj
+1
-0
include/spdlog/details/traits.h
include/spdlog/details/traits.h
+1
-0
include/spdlog/logger.h
include/spdlog/logger.h
+2
-1
include/spdlog/sinks/wincolor_sink.h
include/spdlog/sinks/wincolor_sink.h
+2
-0
No files found.
example/example.cpp
View file @
11e068d7
//
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
...
...
@@ -11,6 +11,10 @@
#define SPDLOG_DEBUG_ON
#include "spdlog/sinks/color_sinks.h"
#include "spdlog/async.h"
#include "spdlog/spdlog.h"
#include <iostream>
...
...
@@ -25,13 +29,28 @@ void err_handler_example();
namespace
spd
=
spdlog
;
int
main
(
int
,
char
*
[])
{
try
{
// Console logger with color
auto
console
=
spdlog
::
console
<
spd
::
stdout_color_mt
>
(
"console"
);
// Console logger with color
spd
::
init_thread_pool
(
8192
,
3
);
auto
console
=
spdlog
::
stdout_color_mt
<
spdlog
::
create_async
>
(
"console1"
);
auto
console2
=
spdlog
::
stderr_logger_mt
<
spdlog
::
create_async
>
(
"console2"
);
//auto console3 = spdlog::stdout_color_mt<spdlog::create_async>("console3");
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
console
->
info
(
"CONSOLE1"
);
console2
->
warn
(
"CONSOLE2"
);
}
spdlog
::
drop_all
();
return
0
;
console
->
info
(
"Welcome to spdlog!"
);
console
->
info
(
"Welcome to spdlog!"
);
console
->
error
(
"Some error message with arg: {}"
,
1
);
err_handler_example
();
// 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
);
...
...
@@ -59,7 +78,8 @@ int main(int, char *[])
daily_logger
->
info
(
123.44
);
// Customize msg format for all messages
spd
::
set_pattern
(
"[%^+++%$] [%H:%M:%S %z] [thread %t] %v"
);
//spd::set_pattern("[%^+++%$] [%H:%M:%S %z] [thread %t] %v"); //crash
console
->
info
(
"This an info message with custom format"
);
console
->
error
(
"This an error message with custom format"
);
...
...
@@ -88,7 +108,7 @@ int main(int, char *[])
user_defined_example
();
// Change default log error handler
err_handler_example
();
err_handler_example
();
// Apply a function on all registered loggers
spd
::
apply_all
([
&
](
std
::
shared_ptr
<
spdlog
::
logger
>
l
)
{
l
->
info
(
"End of example."
);
});
...
...
@@ -162,6 +182,7 @@ void user_defined_example()
void
err_handler_example
()
{
// can be set globaly or per logger(logger->set_error_handler(..))
spdlog
::
set_error_handler
([](
const
std
::
string
&
msg
)
{
std
::
cerr
<<
"my err handler: "
<<
msg
<<
std
::
endl
;
});
spd
::
get
(
"console"
)
->
info
(
"some invalid message to trigger an error {}{}{}{}"
,
3
);
spdlog
::
set_error_handler
([](
const
std
::
string
&
msg
)
{
spd
::
get
(
"console"
)
->
error
(
"*******my err handler: {}"
,
msg
);
});
spd
::
get
(
"console"
)
->
info
(
"some invalid message to trigger an error {}{}{}{}"
,
3
);
//spd::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
}
example/example.vcxproj
View file @
11e068d7
...
...
@@ -27,6 +27,7 @@
<ClInclude
Include=
"..\include\spdlog\details\pattern_formatter_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\registry.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\spdlog_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\thread_pool.h"
/>
<ClInclude
Include=
"..\include\spdlog\fmt\fmt.h"
/>
<ClInclude
Include=
"..\include\spdlog\fmt\ostr.h"
/>
<ClInclude
Include=
"..\include\spdlog\formatter.h"
/>
...
...
include/spdlog/details/traits.h
View file @
11e068d7
...
...
@@ -4,6 +4,7 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "stdio.h"
namespace
spdlog
{
namespace
details
{
struct
console_stdout_trait
...
...
include/spdlog/logger.h
View file @
11e068d7
...
...
@@ -13,7 +13,8 @@
// 3. Pass the formatted message to its sinks to performa the actual logging
#include "common.h"
#include "sinks/base_sink.h"
#include "sinks/sink.h"
#include "formatter.h"
#include <memory>
#include <string>
...
...
include/spdlog/sinks/wincolor_sink.h
View file @
11e068d7
...
...
@@ -5,10 +5,12 @@
#pragma once
#include "sink.h"
#include "../common.h"
#include "../details/null_mutex.h"
#include "../details/traits.h"
#include <mutex>
#include <memory>
#include <string>
...
...
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