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
c6cb6110
Commit
c6cb6110
authored
Dec 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: moved code to log_init_file()
Added log_init_file() and log_init_stdout(), preparing for other logging targets.
parent
d70c2e22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
log.c
src/log.c
+27
-15
No files found.
src/log.c
View file @
c6cb6110
...
...
@@ -64,9 +64,9 @@ static const char *log_date(void)
}
static
void
mpd
_log_func
(
const
gchar
*
log_domain
,
G_GNUC_UNUSED
GLogLevelFlags
log_level
,
const
gchar
*
message
,
G_GNUC_UNUSED
gpointer
user_data
)
file
_log_func
(
const
gchar
*
log_domain
,
G_GNUC_UNUSED
GLogLevelFlags
log_level
,
const
gchar
*
message
,
G_GNUC_UNUSED
gpointer
user_data
)
{
char
*
converted
;
...
...
@@ -93,6 +93,12 @@ mpd_log_func(const gchar *log_domain,
g_free
(
converted
);
}
static
void
log_init_stdout
(
void
)
{
g_log_set_default_handler
(
file_log_func
,
NULL
);
}
static
int
open_log_file
(
void
)
{
...
...
@@ -101,6 +107,18 @@ open_log_file(void)
return
open
(
out_filename
,
O_CREAT
|
O_WRONLY
|
O_APPEND
,
0666
);
}
static
void
log_init_file
(
const
char
*
path
,
unsigned
line
)
{
out_filename
=
path
;
out_fd
=
open_log_file
();
if
(
out_fd
<
0
)
FATAL
(
"problem opening log file
\"
%s
\"
(config line %u) for "
"writing
\n
"
,
path
,
line
);
g_log_set_default_handler
(
file_log_func
,
NULL
);
}
static
inline
GLogLevelFlags
parse_log_level
(
const
char
*
value
,
unsigned
line
)
{
...
...
@@ -121,23 +139,17 @@ void log_init(bool verbose, bool use_stdout)
g_get_charset
(
&
log_charset
);
g_log_set_default_handler
(
mpd_log_func
,
NULL
);
if
(
verbose
)
log_threshold
=
G_LOG_LEVEL_DEBUG
;
else
if
((
param
=
getConfigParam
(
CONF_LOG_LEVEL
))
!=
NULL
)
log_threshold
=
parse_log_level
(
param
->
value
,
param
->
line
);
if
(
use_stdout
)
return
;
param
=
parseConfigFilePath
(
CONF_LOG_FILE
,
1
);
out_filename
=
param
->
value
;
out_fd
=
open_log_file
();
if
(
out_fd
<
0
)
FATAL
(
"problem opening log file
\"
%s
\"
(config line %i) for "
"writing
\n
"
,
param
->
value
,
param
->
line
);
if
(
use_stdout
)
{
log_init_stdout
();
}
else
{
param
=
parseConfigFilePath
(
CONF_LOG_FILE
,
1
);
log_init_file
(
param
->
value
,
param
->
line
);
}
}
void
setup_log_output
(
bool
use_stdout
)
...
...
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