]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'refs/heads/t/ll'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 18 Sep 2022 14:28:33 +0000 (16:28 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 18 Sep 2022 14:35:09 +0000 (16:35 +0200)
Two little cleanups related to the logging facility and two commits
which add the ll command to para_server and para_audiod.

The merge resulted in a conflict in afs.c due to the earlier merge of
the poll topic branch which replaced all calls to select() by calls
to poll(). The implementation of the ll server command introduced a
new caller of select(), afs_select(), which needs to be replaced by
afs_poll() to resolve the conflict.

* refs/heads/t/ll:
  New server command: ll to change the log level at runtime.
  New audiod command: ll to change the log level at runtime.
  daemon: Kill get_loglevel_by_name().
  server/audiod: Don't parse loglevel argument unnecessarily.

21 files changed:
Makefile.real
NEWS.md
afs.c
audioc.c
audiod.c
audiod_command.c
client.c
command.c
daemon.c
daemon.h
error.h
interactive.c
interactive.h
m4/lls/audiod_cmd.suite.m4
m4/lls/include/com_ll.m4 [new file with mode: 0644]
m4/lls/makefile
m4/lls/server_cmd.suite.m4
server.c
server.h
string.c
string.h

index 6e8084d542b8888e2a838671b6a9be845ac2cae2..92ef995249680fabdbcdaa1b257b92fabdfd5d2a 100644 (file)
@@ -10,6 +10,7 @@ endif
 .SHELLFLAGS := -ec
 
 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
+SEVERITIES := \"debug\",\"info\",\"notice\",\"warning\",\"error\",\"crit\",\"emerg\"
 vardir := /var/paraslash
 mandir := $(datarootdir)/man/man1
 MKDIR_P := mkdir -p
@@ -112,6 +113,7 @@ CPPFLAGS += -DBINDIR='"$(bindir)"'
 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
+CPPFLAGS += -DSEVERITIES=$(SEVERITIES)
 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
 CPPFLAGS += -I$(lls_suite_dir)
diff --git a/NEWS.md b/NEWS.md
index 0f2eec0d5e232f5ff11a74bd11860e77ea0e7e56..e5b9901054062c92667c3ab403daa5960dd90603 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -7,12 +7,12 @@ NEWS
 
 - The autogen.sh script now only creates the autoconf specific files
   but no longer runs configure, make and the test suite.
-
 - A stripped down copy of the discontinued libmp4ff library has become
   part of the paraslash code base. As a result it is no longer necessary
   to install faad from source to get support for aac/m4a files. The
   faad decoder package must still be installed.
-
+- The log level of the running daemon can now be changed with the
+  new ll command. It is available for para_server and para_audiod.
 - All calls to select(2) have been replaced by calls to poll(2)
   to avoid known shortcomings of the select API.
 
diff --git a/afs.c b/afs.c
index febe13b3e7c561cf2082ab9200c6578806ab8026..f29080290424d95506ec643df567e24c2d095a74 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -24,6 +24,7 @@
 #include "afs.h"
 #include "net.h"
 #include "server.h"
+#include "daemon.h"
 #include "ipc.h"
 #include "list.h"
 #include "sched.h"
@@ -979,6 +980,14 @@ static void register_command_task(struct sched *s)
        }, s);
 }
 
+static int afs_poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+       mutex_lock(mmd_mutex);
+       daemon_set_loglevel(mmd->loglevel);
+       mutex_unlock(mmd_mutex);
+       return xpoll(fds, nfds, timeout);
+}
+
 /**
  * Initialize the audio file selector process.
  *
@@ -1004,6 +1013,7 @@ __noreturn void afs_init(int socket_fd)
        init_admissible_files(OPT_STRING_VAL(AFS_INITIAL_MODE));
        register_command_task(&s);
        s.default_timeout = 1000;
+       s.poll_function = afs_poll;
        ret = write(socket_fd, "\0", 1);
        if (ret != 1) {
                if (ret == 0)
index 2506c3f8ea6149df47bc84fcb6e5b1b608e70cc5..5f91e3b7d925bf4bd34f67ef0cfeb059a60cef8f 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -107,6 +107,12 @@ static void help_completer(struct i9e_completion_info *ci,
        cr->matches = i9e_complete_commands(ci->word, audiod_completers);
 }
 
+static void ll_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr)
+{
+       i9e_ll_completer(ci, cr);
+}
+
 static void version_completer(struct i9e_completion_info *ci,
                struct i9e_completion_result *cr)
 {
index a084558b167af829d2c0f6a0fbd71a2610c1f3b0..c29cf3ad472dc56a3b5328d2ca9e85e8ea45e288 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -44,8 +44,6 @@ static struct lls_parse_result *lpr;
 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
-#define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \
-       lls_opt(LSG_AUDIOD_PARA_AUDIOD_OPT_ ## _name, CMD_PTR)))
 
 __printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log;
 /** define the array containing all supported audio formats */
@@ -389,7 +387,7 @@ static void parse_config_or_die(void)
                        para_strerror(-ret));
                exit(EXIT_FAILURE);
        }
-       daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL));
+       daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL));
        n = OPT_GIVEN(USER_ALLOW);
        if (n == 0)
                return;
@@ -1462,7 +1460,7 @@ int main(int argc, char *argv[])
        ret = lls(lls_parse(argc, argv, CMD_PTR, &lpr, &errctx));
        if (ret < 0)
                goto out;
-       daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL));
+       daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL));
        daemon_drop_privileges_or_die(OPT_STRING_VAL(USER),
                OPT_STRING_VAL(GROUP));
        version_handle_flag("audiod", OPT_GIVEN(VERSION));
index 795e2ac84657150a1a8d64947e30a7ba4a217796..29c330f36a526d1004cb8595248fb75008033438 100644 (file)
@@ -240,6 +240,42 @@ static int com_help(int fd, struct lls_parse_result *lpr)
 }
 EXPORT_AUDIOD_CMD_HANDLER(help)
 
+static int com_ll(int fd, struct lls_parse_result *lpr)
+{
+       unsigned ll;
+       char *errctx;
+       const char *sev[] = {SEVERITIES};
+       const char *arg;
+       int ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx));
+
+       if (ret < 0) {
+               char *tmp = make_message("%s\n", errctx);
+               free(errctx);
+               client_write(fd, tmp);
+               free(tmp);
+               return ret;
+       }
+       if (lls_num_inputs(lpr) == 0) {
+               char *msg;
+               ll = daemon_get_loglevel();
+               msg = make_message("%s\n", sev[ll]);
+               ret = client_write(fd, msg);
+               free(msg);
+               return ret;
+       }
+       arg = lls_input(0, lpr);
+       for (ll = 0; ll < NUM_LOGLEVELS; ll++) {
+               if (!strcmp(arg, sev[ll]))
+                       break;
+       }
+       if (ll >= NUM_LOGLEVELS)
+               return -ERRNO_TO_PARA_ERROR(EINVAL);
+       PARA_INFO_LOG("new log level: %s\n", sev[ll]);
+       daemon_set_loglevel(ll);
+       return 1;
+}
+EXPORT_AUDIOD_CMD_HANDLER(ll)
+
 static int com_tasks(int fd, __a_unused struct lls_parse_result *lpr)
 {
        int ret;
index ed0d5e02f7881409b4f5c5ce9735a5a42e486555..36e851f4b571a2dc095290f18f5e0d96afc5331e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -246,6 +246,12 @@ I9E_DUMMY_COMPLETER(init);
 
 static struct i9e_completer completers[];
 
+static void ll_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr)
+{
+       i9e_ll_completer(ci, cr);
+}
+
 static void help_completer(struct i9e_completion_info *ci,
                struct i9e_completion_result *cr)
 {
index 200ff054b35f0735cdb41cf09eda14b8b9b77826..0f47110e54b7e661e59b8895e7c79847ad35bae4 100644 (file)
--- a/command.c
+++ b/command.c
@@ -10,7 +10,6 @@
 #include <netdb.h>
 #include <lopsub.h>
 
-#include "server.lsg.h"
 #include "para.h"
 #include "error.h"
 #include "lsu.h"
@@ -391,7 +390,6 @@ static int com_si(struct command_context *cc,
                "server_pid: %d\n"
                "afs_pid: %d\n"
                "connections (active/accepted/total): %u/%u/%u\n"
-               "current loglevel: %s\n"
                "supported audio formats: %s\n",
                ut, mmd->num_played,
                (int)getppid(),
@@ -399,7 +397,6 @@ static int com_si(struct command_context *cc,
                mmd->active_connections,
                mmd->num_commands,
                mmd->num_connects,
-               ENUM_STRING_VAL(LOGLEVEL),
                AUDIO_FORMAT_HANDLERS
        );
        mutex_unlock(mmd_mutex);
@@ -590,6 +587,46 @@ static int com_hup(__a_unused struct command_context *cc,
 }
 EXPORT_SERVER_CMD_HANDLER(hup);
 
+static int com_ll(struct command_context *cc, struct lls_parse_result *lpr)
+{
+       unsigned ll, perms;
+       char *errctx;
+       const char *sev[] = {SEVERITIES}, *arg;
+       int ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx));
+
+       if (ret < 0) {
+               send_errctx(cc, errctx);
+               return ret;
+       }
+       if (lls_num_inputs(lpr) == 0) { /* reporting is an unprivileged op. */
+               const char *severity;
+               mutex_lock(mmd_mutex);
+               severity = sev[mmd->loglevel];
+               mutex_unlock(mmd_mutex);
+               return send_sb_va(&cc->scc, SBD_OUTPUT, "%s\n", severity);
+       }
+       /*
+        * Changing the loglevel changes the state of both the afs and the vss,
+        * so we require both AFS_WRITE and VSS_WRITE.
+        */
+       perms = AFS_WRITE | VSS_WRITE;
+       if ((cc->u->perms & perms) != perms)
+               return -ERRNO_TO_PARA_ERROR(EPERM);
+       arg = lls_input(0, lpr);
+       for (ll = 0; ll < NUM_LOGLEVELS; ll++)
+               if (!strcmp(arg, sev[ll]))
+                       break;
+       if (ll >= NUM_LOGLEVELS)
+               return -ERRNO_TO_PARA_ERROR(EINVAL);
+       PARA_INFO_LOG("new log level: %s\n", sev[ll]);
+       /* Ask the server and afs processes to adjust their log level. */
+       mutex_lock(mmd_mutex);
+       mmd->loglevel = ll;
+       mutex_unlock(mmd_mutex);
+       return 1;
+}
+EXPORT_SERVER_CMD_HANDLER(ll);
+
 static int com_term(__a_unused struct command_context *cc,
                __a_unused struct lls_parse_result *lpr)
 {
index dd5420a6eab92de518e3af60ea49d094ae5db6bb..1fff16beb39ee71a5244ad2b38f3855306270da7 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -64,18 +64,24 @@ static void daemon_set_default_log_colors(void)
  */
 void daemon_set_log_color_or_die(const char *arg)
 {
+       unsigned ll;
+       const char * const sev[] = {SEVERITIES};
        char *p = strchr(arg, ':');
-       int ret, ll;
 
        if (!p)
                goto err;
-       ret = get_loglevel_by_name(arg);
-       if (ret < 0)
-               goto err;
-       ll = ret;
-       p++;
-       color_parse_or_die(p, me->log_colors[ll]);
-       return;
+       for (ll = 0; ll < NUM_LOGLEVELS; ll++) {
+               const char *name = sev[ll];
+               /*
+                * Parse only the first part of the string so that, for
+                * example, the argument "info:something_else" is recognized.
+                * Note that the string comparison is performed
+                * case-insensitively.
+                */
+               if (strncasecmp(arg, name, strlen(name)))
+                       continue;
+               return color_parse_or_die(p + 1, me->log_colors[ll]);
+       }
 err:
        PARA_EMERG_LOG("%s: invalid color argument\n", arg);
        exit(EXIT_FAILURE);
@@ -134,16 +140,29 @@ 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;
+/**
+ * Get the current log level of the daemon.
+ *
+ * \return Greater or equal than zero and less than NUM_LOGLEVELS. This
+ * function never fails.
+ */
+int daemon_get_loglevel(void)
+{
+       return me->loglevel;
 }
 
 /**
index b530b0d76b48b673fd7ae7626c48a6dd91ab7751..54879924954d0352d25cec928c1bcff9a6f9e58e 100644 (file)
--- a/daemon.h
+++ b/daemon.h
@@ -13,7 +13,8 @@ __malloc char *daemon_get_uptime_str(const struct timeval *current_time);
 void daemon_set_logfile(const char *logfile_name);
 void daemon_set_hooks(void (*pre_log_hook)(void), void (*post_log_hook)(void));
 void daemon_set_flag(unsigned flag);
-void daemon_set_loglevel(const char *loglevel);
+int daemon_get_loglevel(void);
+void daemon_set_loglevel(int loglevel);
 bool daemon_init_colors_or_die(int color_arg, int color_arg_auto,
                int color_arg_no, bool logfile_given);
 void daemon_set_log_color_or_die(const char *arg);
diff --git a/error.h b/error.h
index 40081b6b3551712f051ed3ecc4d1ca40ebf2d4f8..f119b87ec828b0d99a1dcddd6ff2f85dbb244b2f 100644 (file)
--- a/error.h
+++ b/error.h
@@ -51,7 +51,6 @@
        PARA_ERROR(BAD_CT, "invalid chunk table or bad FEC configuration"), \
        PARA_ERROR(BAD_FEATURE, "invalid feature request"), \
        PARA_ERROR(BAD_FEC_HEADER, "invalid fec header"), \
-       PARA_ERROR(BAD_LL, "invalid loglevel"), \
        PARA_ERROR(BAD_PATH, "invalid path"), \
        PARA_ERROR(BAD_PRIVATE_KEY, "invalid private key"), \
        PARA_ERROR(BAD_SAMPLE_FORMAT, "sample format not supported"), \
index 812a7d5bef8a37bd3ebdbd5a2484b735827a3395..baacdc00bbdc3029052b5f2709e32673fb634557 100644 (file)
@@ -796,3 +796,25 @@ create_matches:
        free(ci.word);
        return ret;
 }
+
+/**
+ * Complete on severity strings.
+ *
+ * \param ci See struct \ref i9e_completer.
+ * \param cr See struct \ref i9e_completer.
+ *
+ * This is used by para_client and para_audioc which need the same completion
+ * primitive for the ll server/audiod command. Both define their own completer
+ * which is implemented as a trivial wrapper that calls this function.
+ */
+void i9e_ll_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr)
+{
+       char *sev[] = {SEVERITIES, NULL};
+
+       if (ci->word_num != 1) {
+               cr->matches = NULL;
+               return;
+       }
+       i9e_extract_completions(ci->word, sev, &cr->matches);
+}
index 53b1ad347e6f5b108814e8db309c5434272e9ab7..6ef7f8e259b0045a5c808c01560b5a81166b01fd 100644 (file)
@@ -92,3 +92,5 @@ void i9e_complete_option(char **opts, struct i9e_completion_info *ci,
                struct i9e_completion_result *cr);
 int i9e_print_completions(struct i9e_completer *completers);
 int i9e_get_error(void);
+void i9e_ll_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr);
index 80ae2e42be9773f0e619e1746b9bfdefbe02f2c4..bd2a23e2354dde09cc8090a08ccf6ad31d7ac9b9 100644 (file)
@@ -51,6 +51,8 @@ caption = list of audiod commands
                short_opt = o
                summary = One-shot mode: Stop grabbing if audio file changes
 
+m4_include(`com_ll.m4')
+
 [subcommand off]
        purpose = deactivate para_audiod
        [description]
diff --git a/m4/lls/include/com_ll.m4 b/m4/lls/include/com_ll.m4
new file mode 100644 (file)
index 0000000..d7576ea
--- /dev/null
@@ -0,0 +1,10 @@
+[subcommand ll]
+       purpose = Query or set the log level of the daemon
+       m4_ifelse(SUITE, `server_cmd', `aux_info = NO_PERMISSION_REQUIRED')
+       non-opts-name = [severity]
+       [description]
+               If no argument is given, the command prints the severity string (one
+               of the possible string arguments to --loglevel) which corresponds to
+               the current loglevel. Otherwise, if the given argument is a severity
+               string, the current log level is set accordingly.
+       [/description]
index daf6de92525d334d3c1791e4d0b53907ddd7fb7f..a13f079e9b60195240bb48f3b847978263a486bc 100644 (file)
@@ -11,6 +11,7 @@ $(lls_suite_dir)/%.suite: $(lls_m4_dir)/%.suite.m4 | $(lls_suite_dir)
        $(call SAY, M4 $<)
        $(M4) -Pg -I $(lls_m4_include_dir) -D GIT_VERSION=$(GIT_VERSION) \
                -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) -D LOGLEVELS=$(LOGLEVELS) \
+               -D SUITE=$(basename $(notdir $<)) \
                $< > $@
 
 $(lls_suite_dir)/%.lsg.c: $(lls_suite_dir)/%.suite
index f73d66b26a713ce70ed144e38362a73f5ddcf8c1..8200c6249449f81b5743775f04796462fc912b83 100644 (file)
@@ -169,6 +169,8 @@ aux_info_prefix = Permissions:
                playlists. Otherwise only the given tables are created.
        [/description]
 
+m4_include(`com_ll.m4')
+
 [subcommand jmp]
        purpose = reposition the current stream
        non-opts-name = n
index 2c66cc279c9faa99e009ae747fd4d8a54738e2e8..2852ee1f10f7a9d8d4f5a93e2233b8b6fd4a4ecc 100644 (file)
--- a/server.c
+++ b/server.c
@@ -172,6 +172,7 @@ static void init_ipc_or_die(void)
        mmd->active_connections = 0;
        mmd->vss_status_flags = VSS_NEXT;
        mmd->new_vss_status_flags = VSS_NEXT;
+       mmd->loglevel = OPT_UINT32_VAL(LOGLEVEL);
        return;
 destroy_mmd_mutex:
        mutex_destroy(mmd_mutex);
@@ -180,6 +181,9 @@ err_out:
        exit(EXIT_FAILURE);
 }
 
+/** Get a reference to the supercommand of para_server. */
+#define CMD_PTR (lls_cmd(0, server_suite))
+
 /**
  * (Re-)read the server configuration files.
  *
@@ -205,7 +209,7 @@ void parse_config_or_die(bool reload)
                        para_strerror(-ret));
                exit(EXIT_FAILURE);
        }
-       daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL));
+       daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL));
        if (OPT_GIVEN(LOGFILE)) {
                daemon_set_logfile(OPT_STRING_VAL(LOGFILE));
                daemon_open_log_or_die();
@@ -543,7 +547,7 @@ static void server_init(int argc, char **argv, struct server_command_task *sct)
        if (ret < 0)
                goto fail;
        server_lpr = cmdline_lpr;
-       daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL));
+       daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL));
        daemon_drop_privileges_or_die(OPT_STRING_VAL(USER),
                OPT_STRING_VAL(GROUP));
        version_handle_flag("server", OPT_GIVEN(VERSION));
@@ -621,6 +625,7 @@ static int server_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
        int ret;
 
+       daemon_set_loglevel(mmd->loglevel);
        status_refresh();
        mutex_unlock(mmd_mutex);
        ret = xpoll(fds, nfds, timeout);
index da75d86bdf191b130d02da12f49172ac5e0482d7..10bb6172860ddb467c3f9fd26ef6ce9e3cb8aab1 100644 (file)
--- a/server.h
+++ b/server.h
@@ -73,6 +73,8 @@ struct misc_meta_data {
        char afs_mode_string[MAXLINE];
        /** Used by the sender command. */
        struct sender_command_data sender_cmd_data;
+       /** Set by the ll command. */
+       int loglevel;
        /** Describes the current audio file. */
        struct audio_file_data afd;
 };
@@ -80,15 +82,6 @@ struct misc_meta_data {
 extern pid_t afs_pid;
 extern struct lls_parse_result *server_lpr;
 
-/**
- * Get a reference to the supercommand of para_server.
- *
- * This is needed for parsing the command line and for the ENUM_STRING_VAL()
- * macro below. The latter macro is used in command.c, so CMD_PTR() can not
- * be made local to server.c.
- */
-#define CMD_PTR (lls_cmd(0, server_suite))
-
 /** Get the parse result of an option to para_server. */
 #define OPT_RESULT(_name) (lls_opt_result( \
                LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))
@@ -105,10 +98,6 @@ extern struct lls_parse_result *server_lpr;
 /** The (first) argument to a server option of type int32. */
 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
 
-/** Get the string which corresponds to an enum constant. */
-#define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \
-       lls_opt(LSG_SERVER_PARA_SERVER_OPT_ ## _name, CMD_PTR)))
-
 int handle_connect(int fd);
 void parse_config_or_die(bool reload);
 char *server_get_tasks(void);
index f80331900de09fccf573c18666c3fa007f8ca6bf..0e04d3740b499b3db6721690d3c30419758b8371 100644 (file)
--- a/string.c
+++ b/string.c
@@ -552,37 +552,6 @@ int para_atoi32(const char *str, int32_t *value)
        return 1;
 }
 
-static inline int loglevel_equal(const char *arg, const char * const ll)
-{
-       return !strncasecmp(arg, ll, strlen(ll));
-}
-
-/**
- * Compute the loglevel number from its name.
- *
- * \param txt The name of the loglevel (debug, info, ...).
- *
- * \return The numeric representation of the loglevel name.
- */
-int get_loglevel_by_name(const char *txt)
-{
-       if (loglevel_equal(txt, "debug"))
-               return LL_DEBUG;
-       if (loglevel_equal(txt, "info"))
-               return LL_INFO;
-       if (loglevel_equal(txt, "notice"))
-               return LL_NOTICE;
-       if (loglevel_equal(txt, "warning"))
-               return LL_WARNING;
-       if (loglevel_equal(txt, "error"))
-               return LL_ERROR;
-       if (loglevel_equal(txt, "crit"))
-               return LL_CRIT;
-       if (loglevel_equal(txt, "emerg"))
-               return LL_EMERG;
-       return -E_BAD_LL;
-}
-
 static int get_next_word(const char *buf, const char *delim, char **word)
 {
        enum line_state_flags {LSF_HAVE_WORD = 1, LSF_BACKSLASH = 2,
index 08b9965f57d94b52a19dd231c38b2d53aabb824a..84b6f787924f18a805eea6b5d2730a4ffa230159 100644 (file)
--- a/string.h
+++ b/string.h
@@ -82,7 +82,6 @@ __malloc char *para_hostname(void);
 __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...);
 int para_atoi64(const char *str, int64_t *result);
 int para_atoi32(const char *str, int32_t *value);
-int get_loglevel_by_name(const char *txt);
 int read_size_header(const char *buf);
 int create_argv(const char *buf, const char *delim, char ***result);
 int create_shifted_argv(const char *buf, const char *delim, char ***result);