]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - daemon.c
server/audiod: Don't parse loglevel argument unnecessarily.
[paraslash.git] / daemon.c
index bfa81487430f62dc7417db6ba6e0c6d53c008051..04dbc122386274110975bb155a5686ef9520f940 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -58,9 +58,9 @@ static void daemon_set_default_log_colors(void)
 }
 
 /**
- * Set the color for one loglevel.
+ * Set the color for log messages of the given severity level.
  *
- * \param arg Must be of the form "ll:[fg [bg]] [attr]".
+ * \param arg Must be of the form "severity:[fg [bg]] [attr]".
  */
 void daemon_set_log_color_or_die(const char *arg)
 {
@@ -134,18 +134,37 @@ void daemon_set_logfile(const char *logfile_name)
 }
 
 /**
- * Suppress log messages with severity lower than the given loglevel.
+ * Control the verbosity for logging.
  *
- * \param loglevel The smallest level that should be logged.
+ * This instructs the daemon to not log subsequent messages whose severity is
+ * lower than the given value.
+ *
+ * \param loglevel The new log level.
  */
-void daemon_set_loglevel(const char *loglevel)
+void daemon_set_loglevel(int loglevel)
 {
-       int ret = get_loglevel_by_name(loglevel);
+       assert(loglevel >= 0);
+       assert(loglevel < NUM_LOGLEVELS);
+       me->loglevel = loglevel;
 
-       assert(ret >= 0);
-       me->loglevel = ret;
 }
 
+/**
+ * Register functions to be called before and after a message is logged.
+ *
+ * \param pre_log_hook Called before the message is logged.
+ * \param post_log_hook Called after the message is logged.
+ *
+ * The purpose of this function is to provide a primitive for multi-threaded
+ * applications to serialize the access to the log facility, preventing
+ * interleaving log messages. This can be achieved by having the pre-log hook
+ * acquire a lock which blocks the other threads on the attempt to log a
+ * message at the same time.  The post-log hook is responsible for releasing
+ * the lock.
+ *
+ * If these hooks are unnecessary, for example because the application is
+ * single-threaded, this function does not need to be called.
+ */
 void daemon_set_hooks(void (*pre_log_hook)(void), void (*post_log_hook)(void))
 {
        me->pre_log_hook = pre_log_hook;