Commit Graph

84 Commits

Author SHA1 Message Date
Max Kellermann
8e5f9c8160 conf: turn config_get_path() into config_dup_path()
config_get_path() was somewhat flawed, because it pretended to be a
function, when it really had a side effect.  The second flaw was that
it did not return the parser error, instead it aborted the whole
process, which is bad style.  The new function returns a duplicated
(modified) string that must be freed by the caller, and returns a
GError on failure.
2011-09-09 22:55:57 +02:00
Max Kellermann
2a859f870a log: print detailed errno message on open() failure 2011-09-09 21:53:42 +02:00
Max Kellermann
b680753db8 log: return GError on initialization failure 2011-09-09 21:53:42 +02:00
Max Kellermann
c6cbcc2c25 copyright year 2011 2011-01-29 10:13:54 +01:00
Thomas Jansen
28bcb8bdf5 eliminate g_error() usage
Replaced all occurrences of g_error() with MPD_ERROR() located in a new header
file 'mpd_error.h'. This macro uses g_critical() to print the error message
and then exits gracefully in contrast to g_error() which would internally call
abort() to produce a core dump.

The macro name is distinctive and allows to find all places with dubious error
handling. The long-term goal is to get rid of MPD_ERROR() altogether. To
facilitate the eventual removal of this macro it was added in a new header
file rather than to an existing header file.

This fixes #2995 and #3007.
2010-09-25 15:00:43 +02:00
Avuton Olrich
eb5208c4f9 log: /dev/null doesn't exist on win32. 2010-05-08 00:17:34 -07:00
Avuton Olrich
9d3865cb95 Update copyright notices. 2009-12-31 20:58:43 -08:00
Max Kellermann
5b82ffc291 include config.h in all sources
After we've been hit by Large File Support problems several times in
the past week (which only occur on 32 bit platforms, which I don't
have), this is yet another attempt to fix the issue.
2009-11-12 09:17:03 +01:00
Max Kellermann
e0e6813a1d fd_util: removed creat_cloexec()
Add a "mode" argument to open_cloexec() instead.
2009-11-10 16:53:24 +01:00
Max Kellermann
e3af0032b2 set the close-on-exec flag on all file descriptors
Added the "fd_util" library, which attempts to use the new thread-safe
Linux system calls pipe2(), accept4() and the options O_CLOEXEC,
SOCK_CLOEXEC.  Without these, it falls back to FD_CLOEXEC, which is
not thread safe.

This is particularly important for the "pipe" output plugin (and
others, such as JACK/PulseAudio), because we were heavily leaking file
descriptors to child processes.
2009-11-07 18:55:16 +01:00
Max Kellermann
c440faa94d log: redirect stdout/stderr to /dev/null if syslog is used
Don't hold a file descriptor on root's tty when syslog is used for
logging.
2009-11-07 17:48:57 +01:00
Max Kellermann
badb827712 log: fix double free() bug during shutdown
Don't free an internal configuration value in log_init().  Call
config_get_path() instead of manually calling parsePath().
2009-07-05 07:14:24 +02:00
Max Kellermann
548e842799 log: removed "unused" attribute from log_level parameter 2009-04-10 09:14:21 +02:00
Max Kellermann
a899c210b9 log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
2009-03-15 18:23:00 +01:00
Avuton Olrich
0aee49bdf8 all: Update copyright header.
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
2009-03-13 11:51:55 -07:00
Max Kellermann
eac2da635d added G_LOG_DOMAIN macros to several libraries
Define the GLib logging domain in the following libraries: conf,
daemon, event_pipe, log.
2009-02-19 09:24:59 +01:00
Max Kellermann
0a0736fc4e log: added log_early_init() for early debug messages 2009-02-19 08:35:20 +01:00
Max Kellermann
5f77910097 conf: const pointers in block get functions
All config_get_block_*() functions should accept constant config_param
pointers.
2009-01-25 16:03:49 +01:00
Max Kellermann
4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann
29baf0c190 log, pcm_convert: added return statements after g_error()
gcc doesn't know that g_error() never returns.  Work around the gcc
warning.
2009-01-15 09:17:06 +01:00
Max Kellermann
3cb3baa1e2 log: don't call closelog() on !HAVE_SYSLOG 2009-01-03 13:20:01 +01:00
Max Kellermann
6517126204 log: removed unused logging wrappers
Removed GLib logging wrappers which are not used anymore.
2008-12-29 17:35:42 +01:00
Max Kellermann
3fa5632704 log: automatically append newline
If a log message does not include a newline character, append it.
2008-12-29 17:28:34 +01:00
Thomas Jansen
5e3dc6946f Include <pthread.h> where it is necessary only 2008-12-28 21:02:05 +01:00
Max Kellermann
7f78ed5b98 log: use GLib logging 2008-12-28 19:48:53 +01:00
Max Kellermann
59cf77bbc8 log: don't keep log file open
The log file is duped to STDOUT_FILENO and STDERR_FILENO.  No need to
keep another copy of it in out_fd all the time.  We only need it once
once in setup_log_output().
2008-12-28 19:48:53 +01:00
Max Kellermann
c01aa53e6a log: support syslog()
Allow logging to syslog if log_file is configured to "syslog".
2008-12-28 19:48:53 +01:00
Max Kellermann
c6cb611065 log: moved code to log_init_file()
Added log_init_file() and log_init_stdout(), preparing for other
logging targets.
2008-12-28 19:48:53 +01:00
Max Kellermann
d70c2e2285 log: merged initLog() and open_log_files().
The logging library currently has 3 constructor functions: initLog(),
open_log_files(), setup_log_output(), called in this order.  Merged
the first two.
2008-12-28 19:48:53 +01:00
Max Kellermann
caf47f7893 log: moved code to parse_log_level() 2008-12-28 19:48:53 +01:00
Max Kellermann
5d2c59e3f1 log: use the GLogLevelFlags type
Declare log_threshold as GLogLevelFlags.
2008-12-28 19:48:53 +01:00
Max Kellermann
2c5885e9c7 log: don't manipulate the umask
If the user wants the log files with a specific mode, he has to start
MPD with the correct umask.  Don't hard-code that.

This fixes a bug: when log cycling failed, MPD would not restore the
old umask.
2008-12-28 19:48:52 +01:00
Max Kellermann
8e9def1b5a log: moved code to open_log_file()
Merged code from open_log_files() and cycle_log_files().
2008-12-28 19:48:52 +01:00
Max Kellermann
8dc92ad284 log: deprecated "error_file" option
Removed the "error_file" option.  There is only one log file now.  If
a user wants to see only the errors, he should configure a log_level.
2008-12-28 19:48:52 +01:00
Max Kellermann
bfaaf425c2 log: map log level "SECURE" to GLib's "INFO"
Make "secure" a log level different from "default".  "secure" should be
right between "default" and "verbose".  Map "default" to Glib's
"MESSAGE" log level.
2008-12-20 17:26:49 +01:00
Thomas Jansen
c06ce44768 replaced mpd_printf etc by G_GNUC_PRINTF
We want to remove gcc.h eventually. This takes care of all the G_GNUC_PRINTF
macros.
2008-12-02 03:00:02 +01:00
Thomas Jansen
e6ae40982e replaced mpd_noreturn by G_GNUC_NORETURN
We want to remove gcc.h eventually. This takes care of all the
G_GNUC_NORETURN macros.
2008-12-02 02:42:19 +01:00
Max Kellermann
0243e1e26d log: print the log_domain 2008-11-21 20:13:00 +01:00
Max Kellermann
4a1ad61e8e log: check the log threshold in log_func()
The threshold was only checked in the deprecated logging functions
(ERROR(), WARNING(), ...).  Add the check to the GLib logging handler.
2008-11-14 18:27:11 +01:00
Daniel Schömer
1256f90825 log: properly check log_threshold 2008-11-09 22:27:58 +01:00
Max Kellermann
5b2e981253 log: check if log_charset is set
When logging to a file, log_charset would be NULL and g_convert()
would abort.
2008-11-05 21:40:08 +01:00
Max Kellermann
130fa94423 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.
2008-11-05 18:39:13 +01:00
Max Kellermann
787c6f5e18 log: use bool
Use the bool data type for flags.
2008-11-05 18:39:10 +01:00
Max Kellermann
4c967a6ba2 log: provide a GLib logging handler
Install a default handler which writes to stdout or stderr, and
prepends a time stamp.  This looks just like the 0.13.x logger.
2008-11-05 18:38:55 +01:00
Max Kellermann
a5348a3786 log: use GLib message logging
The logging functions from log.h are deprecated, and the code should
use GLib logging instead.  Make ERROR(), WARNING() etc. call g_logv()
internally.
2008-11-05 18:38:30 +01:00
Max Kellermann
a05fa5cdbb log: no CamelCase
Renamed the variable "logLevel" to "log_threshold".
2008-11-05 18:38:23 +01:00
Max Kellermann
08aaf57ff0 log: removed warning buffer
The warning buffer is a complex piece of code for no good reason.
Remove it and find a better solution, e.g. open the log file earlier.
2008-11-05 18:37:40 +01:00
Max Kellermann
8f3d962219 log: don't use utils.h
Prefer GLib over utils.h.
2008-10-29 21:02:22 +01:00
Max Kellermann
71351160b1 don't include os_compat.h
When there are standardized headers, use these instead of the bloated
os_compat.h.
2008-10-08 10:49:29 +02:00
Max Kellermann
a34e1d2b84 include cleanup
As usual, include only headers which are really needed.
2008-09-06 20:28:31 +02:00