Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
130fa944
Commit
130fa944
authored
Nov 05, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: convert messages to system charset
When logging to the terminal, we should print messages in the system character set. Convert all messages in this case.
parent
787c6f5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
log.c
src/log.c
+14
-0
No files found.
src/log.c
View file @
130fa944
...
...
@@ -40,6 +40,8 @@
static
unsigned
int
log_threshold
=
G_LOG_LEVEL_INFO
;
static
const
char
*
log_charset
;
static
bool
stdout_mode
=
true
;
static
int
out_fd
=
-
1
;
static
int
err_fd
=
-
1
;
...
...
@@ -71,16 +73,27 @@ mpd_log_func(G_GNUC_UNUSED const gchar *log_domain,
{
FILE
*
file
=
log_level
<=
G_LOG_LEVEL_WARNING
?
stderr
:
stdout
;
char
*
converted
;
converted
=
g_convert_with_fallback
(
message
,
-
1
,
log_charset
,
"utf-8"
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
converted
!=
NULL
)
message
=
converted
;
fprintf
(
file
,
"%s%s"
,
stdout_mode
?
""
:
log_date
(),
message
);
g_free
(
converted
);
}
void
initLog
(
bool
verbose
)
{
ConfigParam
*
param
;
g_get_charset
(
&
log_charset
);
g_log_set_default_handler
(
mpd_log_func
,
NULL
);
/* unbuffer stdout, stderr is unbuffered by default, leave it */
...
...
@@ -136,6 +149,7 @@ void setup_log_output(bool use_stdout)
if
(
!
use_stdout
)
{
redirect_logs
();
stdout_mode
=
false
;
log_charset
=
NULL
;
}
}
...
...
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