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
e9633a53
Commit
e9633a53
authored
Mar 30, 2016
by
gabime
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/gabime/spdlog
parents
006ac668
0d97696f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
README.md
README.md
+8
-1
example.cpp
example/example.cpp
+1
-1
ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+6
-6
No files found.
README.md
View file @
e9633a53
...
...
@@ -22,7 +22,7 @@ Just copy the source [folder](https://github.com/gabime/spdlog/tree/master/inclu
*
Various log targets:
*
Rotating log files.
*
Daily log files.
*
Console logging.
*
Console logging
(including colors)
.
*
Linux syslog.
*
Easily extendable with custom log targets (just implement a single function in the
[
sink
](
include/spdlog/sinks/sink.h
)
interface).
*
Severity based filtering - threshold levels can be modified in runtime as well as in compile time.
...
...
@@ -133,6 +133,13 @@ int main(int, char* [])
auto
syslog_logger
=
spd
::
syslog_logger
(
"syslog"
,
ident
,
LOG_PID
);
syslog_logger
->
warn
(
"This is warning that will end up in syslog. This is Linux only!"
);
#endif
//colored console sink example
auto
console_out
=
spdlog
::
sinks
::
stderr_sink_st
::
instance
();
auto
color_sink
=
std
::
make_shared
<
spd
::
sinks
::
ansicolor_sink
>
(
console_out
);
// wraps around another sink
auto
color_logger
=
spd
::
details
::
registry
::
instance
().
create
(
"Color"
,
color_sink
);
color_sink
->
set_color
(
spd
::
level
::
info
,
color_sink
->
bold
+
color_sink
->
green
);
color_logger
->
info
(
"Testing color logger..."
);
}
catch
(
const
spd
::
spdlog_ex
&
ex
)
{
...
...
example/example.cpp
View file @
e9633a53
...
...
@@ -113,7 +113,7 @@ void color_example()
auto
color_sink
=
std
::
make_shared
<
spd
::
sinks
::
ansicolor_sink
>
(
console_out
);
// wraps around another sink
auto
color_logger
=
spd
::
details
::
registry
::
instance
().
create
(
"Color"
,
color_sink
);
color_logger
->
set_level
(
spd
::
level
::
trace
);
color_sink
->
set
C
olor
(
spd
::
level
::
info
,
color_sink
->
bold
+
color_sink
->
green
);
color_sink
->
set
_c
olor
(
spd
::
level
::
info
,
color_sink
->
bold
+
color_sink
->
green
);
color_logger
->
info
(
"Testing color logger..."
);
color_logger
->
trace
(
"Trace"
);
color_logger
->
debug
(
"Debug"
);
...
...
include/spdlog/sinks/ansicolor_sink.h
View file @
e9633a53
//
// Copyright(c) 2016 Kevin M. Godby.
// Copyright(c) 2016 Kevin M. Godby
(modified version by spdlog)
.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
...
...
@@ -21,7 +21,7 @@ namespace sinks {
*/
class
ansicolor_sink
:
public
sink
{
public
:
ansicolor_sink
(
sink_ptr
sink
);
ansicolor_sink
(
sink_ptr
wrapped_
sink
);
virtual
~
ansicolor_sink
();
ansicolor_sink
(
const
ansicolor_sink
&
other
);
...
...
@@ -30,7 +30,7 @@ public:
virtual
void
log
(
const
details
::
log_msg
&
msg
)
override
;
virtual
void
flush
()
override
;
void
set
C
olor
(
level
::
level_enum
level
,
const
std
::
string
&
color
);
void
set
_c
olor
(
level
::
level_enum
level
,
const
std
::
string
&
color
);
/// \name Formatting codes
//@{
...
...
@@ -73,7 +73,7 @@ protected:
std
::
map
<
level
::
level_enum
,
std
::
string
>
colors_
;
};
inline
ansicolor_sink
::
ansicolor_sink
(
sink_ptr
sink
)
:
sink_
(
sink
)
inline
ansicolor_sink
::
ansicolor_sink
(
sink_ptr
wrapped_sink
)
:
sink_
(
wrapped_
sink
)
{
colors_
[
level
::
trace
]
=
white
;
colors_
[
level
::
debug
]
=
white
;
...
...
@@ -115,7 +115,7 @@ inline void ansicolor_sink::log(const details::log_msg& msg)
const
std
::
string
s
=
msg
.
formatted
.
str
();
const
std
::
string
suffix
=
reset
;
details
::
log_msg
m
;
m
.
formatted
.
write
(
prefix
+
s
+
suffix
)
;
m
.
formatted
<<
prefix
<<
s
<<
suffix
;
sink_
->
log
(
m
);
}
...
...
@@ -124,7 +124,7 @@ inline void ansicolor_sink::flush()
sink_
->
flush
();
}
inline
void
ansicolor_sink
::
set
C
olor
(
level
::
level_enum
level
,
const
std
::
string
&
color
)
inline
void
ansicolor_sink
::
set
_c
olor
(
level
::
level_enum
level
,
const
std
::
string
&
color
)
{
colors_
[
level
]
=
color
;
}
...
...
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