Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
ea6a019d
Commit
ea6a019d
authored
3 years ago
by
Olivier Dion
Browse files
Options
Downloads
Patches
Plain Diff
logger: Add NO_COLOR for console logger
Change-Id: I02ccb3c2d05aaa14a7f42dd0c6e2854f9905ccf2
parent
21c8feb7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/logger.cpp
+18
-2
18 additions, 2 deletions
src/logger.cpp
with
18 additions
and
2 deletions
src/logger.cpp
+
18
−
2
View file @
ea6a019d
...
...
@@ -297,6 +297,17 @@ public:
virtual
void
consume
(
jami
::
Logger
::
Msg
&
msg
)
override
{
static
bool
no_color
=
(
getenv
(
"NO_COLOR"
)
||
getenv
(
"NO_COLORS"
)
||
getenv
(
"NO_COLOUR"
)
||
getenv
(
"NO_COLOURS"
));
#if defined(_WIN32) && !defined(RING_UWP)
WORD
saved_attributes
;
HANDLE
hConsole
;
#endif
if
(
not
no_color
)
{
#ifndef _WIN32
const
char
*
color_header
=
CYAN
;
const
char
*
color_prefix
=
""
;
...
...
@@ -305,9 +316,9 @@ public:
WORD
color_header
=
CYAN
;
#endif
#if defined(_WIN32) && !defined(RING_UWP)
HANDLE
hConsole
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
hConsole
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
CONSOLE_SCREEN_BUFFER_INFO
consoleInfo
;
WORD
saved_attributes
;
#endif
switch
(
msg
.
level_
)
{
...
...
@@ -335,6 +346,9 @@ public:
SetConsoleTextAttribute
(
hConsole
,
saved_attributes
);
SetConsoleTextAttribute
(
hConsole
,
color_prefix
);
#endif
}
else
{
fputs
(
msg
.
header_
.
c_str
(),
stderr
);
}
fputs
(
msg
.
payload_
.
get
(),
stderr
);
...
...
@@ -342,11 +356,13 @@ public:
putc
(
ENDL
,
stderr
);
}
if
(
not
no_color
)
{
#ifndef _WIN32
fputs
(
END_COLOR
,
stderr
);
#elif !defined(RING_UWP)
SetConsoleTextAttribute
(
hConsole
,
saved_attributes
);
#endif
}
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment