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
b680753d
Commit
b680753d
authored
Sep 09, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: return GError on initialization failure
parent
35af9401
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
+34
-11
log.c
src/log.c
+19
-9
log.h
src/log.h
+9
-1
main.c
src/main.c
+6
-1
No files found.
src/log.c
View file @
b680753d
...
...
@@ -133,16 +133,20 @@ open_log_file(void)
return
open_cloexec
(
out_filename
,
O_CREAT
|
O_WRONLY
|
O_APPEND
,
0666
);
}
static
void
log_init_file
(
const
char
*
path
,
unsigned
line
)
static
bool
log_init_file
(
const
char
*
path
,
unsigned
line
,
GError
**
error_r
)
{
out_filename
=
path
;
out_fd
=
open_log_file
();
if
(
out_fd
<
0
)
MPD_ERROR
(
"problem opening log file
\"
%s
\"
(config line %u) "
"for writing
\n
"
,
path
,
line
);
if
(
out_fd
<
0
)
{
g_set_error
(
error_r
,
log_quark
(),
errno
,
"problem opening log file
\"
%s
\"
(config line %u) "
"for writing"
,
path
,
line
);
return
false
;
}
g_log_set_default_handler
(
file_log_func
,
NULL
);
return
true
;
}
#ifdef HAVE_SYSLOG
...
...
@@ -232,7 +236,8 @@ log_early_init(bool verbose)
log_init_stdout
();
}
void
log_init
(
bool
verbose
,
bool
use_stdout
)
bool
log_init
(
bool
verbose
,
bool
use_stdout
,
GError
**
error_r
)
{
const
struct
config_param
*
param
;
...
...
@@ -245,6 +250,7 @@ void log_init(bool verbose, bool use_stdout)
if
(
use_stdout
)
{
log_init_stdout
();
return
true
;
}
else
{
param
=
config_get_param
(
CONF_LOG_FILE
);
if
(
param
==
NULL
)
{
...
...
@@ -252,19 +258,23 @@ void log_init(bool verbose, bool use_stdout)
/* no configuration: default to syslog (if
available) */
log_init_syslog
();
return
true
;
#else
MPD_ERROR
(
"config parameter
\"
%s
\"
not found
\n
"
,
CONF_LOG_FILE
);
g_set_error
(
error_r
,
log_quark
(),
0
,
"config parameter
\"
%s
\"
not found"
,
CONF_LOG_FILE
);
return
false
;
#endif
#ifdef HAVE_SYSLOG
}
else
if
(
strcmp
(
param
->
value
,
"syslog"
)
==
0
)
{
log_init_syslog
();
return
true
;
#endif
}
else
{
const
char
*
path
=
config_get_path
(
CONF_LOG_FILE
);
assert
(
path
!=
NULL
);
log_init_file
(
path
,
param
->
line
);
return
log_init_file
(
path
,
param
->
line
,
error_r
);
}
}
}
...
...
src/log.h
View file @
b680753d
...
...
@@ -23,6 +23,13 @@
#include <glib.h>
#include <stdbool.h>
G_GNUC_CONST
static
inline
GQuark
log_quark
(
void
)
{
return
g_quark_from_static_string
(
"log"
);
}
/**
* Configure a logging destination for daemon startup, before the
* configuration file is read. This allows the daemon to use the
...
...
@@ -34,7 +41,8 @@
void
log_early_init
(
bool
verbose
);
void
log_init
(
bool
verbose
,
bool
use_stdout
);
bool
log_init
(
bool
verbose
,
bool
use_stdout
,
GError
**
error_r
);
void
setup_log_output
(
bool
use_stdout
);
...
...
src/main.c
View file @
b680753d
...
...
@@ -332,7 +332,12 @@ int mpd_main(int argc, char *argv[])
stats_global_init
();
tag_lib_init
();
log_init
(
options
.
verbose
,
options
.
log_stderr
);
if
(
!
log_init
(
options
.
verbose
,
options
.
log_stderr
,
&
error
))
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
EXIT_FAILURE
;
}
success
=
listen_global_init
(
&
error
);
if
(
!
success
)
{
...
...
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