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
3ce9ac74
Commit
3ce9ac74
authored
May 10, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mutex protect set_color_mode()
parent
3b0e7b4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+11
-5
wincolor_sink.h
include/spdlog/sinks/wincolor_sink.h
+12
-5
No files found.
include/spdlog/sinks/ansicolor_sink.h
View file @
3ce9ac74
...
...
@@ -38,7 +38,7 @@ public:
,
mutex_
(
ConsoleMutex
::
mutex
())
{
set_color_mode
(
mode
);
set_color_mode
_
(
mode
);
colors_
[
level
::
trace
]
=
white
;
colors_
[
level
::
debug
]
=
cyan
;
colors_
[
level
::
info
]
=
green
;
...
...
@@ -139,22 +139,28 @@ public:
}
void
set_color_mode
(
color_mode
mode
)
{
std
::
lock_guard
<
mutex_t
>
lock
(
mutex_
);
set_color_mode_
(
mode
);
}
private
:
void
set_color_mode_
(
color_mode
mode
)
{
switch
(
mode
)
{
case
color_mode
:
:
always
:
should_do_colors_
=
true
;
return
;
break
;
case
color_mode
:
:
automatic
:
should_do_colors_
=
details
::
os
::
in_terminal
(
target_file_
)
&&
details
::
os
::
is_color_terminal
();
return
;
break
;
case
color_mode
:
:
never
:
should_do_colors_
=
false
;
return
;
break
;
}
}
private
:
void
print_ccode_
(
const
std
::
string
&
color_code
)
{
fwrite
(
color_code
.
data
(),
sizeof
(
char
),
color_code
.
size
(),
target_file_
);
...
...
include/spdlog/sinks/wincolor_sink.h
View file @
3ce9ac74
...
...
@@ -41,7 +41,7 @@ public:
:
out_handle_
(
OutHandle
::
handle
())
,
mutex_
(
ConsoleMutex
::
mutex
())
{
set_color_mode
(
mode
);
set_color_mode
_
(
mode
);
colors_
[
level
::
trace
]
=
WHITE
;
colors_
[
level
::
debug
]
=
CYAN
;
colors_
[
level
::
info
]
=
GREEN
;
...
...
@@ -108,21 +108,28 @@ public:
}
void
set_color_mode
(
color_mode
mode
)
{
std
::
lock_guard
<
mutex_t
>
lock
(
mutex_
);
set_color_mode_
(
mode
);
}
private
:
using
mutex_t
=
typename
ConsoleMutex
::
mutex_t
;
void
set_color_mode_
(
color_mode
mode
)
{
switch
(
mode
)
{
case
color_mode
:
:
always
:
case
color_mode
:
:
automatic
:
should_do_colors_
=
true
;
return
;
break
case
color_mode
:
:
never
:
should_do_colors_
=
false
;
return
;
break
}
}
private
:
using
mutex_t
=
typename
ConsoleMutex
::
mutex_t
;
// set color and return the orig console attributes (for resetting later)
WORD
set_console_attribs
(
WORD
attribs
)
{
...
...
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