mirror of
https://github.com/AuxXxilium/kmod.git
synced 2025-01-27 17:23:43 +07:00
tools: share setting up libkmod log
This also fixes a bug in "e6996c5 rmmod: route all messages to syslog if told to" in which "+ verbose" was removed. Instead of letting verbose add to kmod_get_log_priority(), let it be similar to the other programs instead.
This commit is contained in:
parent
92aad74925
commit
52a50fe2e5
@ -2673,7 +2673,8 @@ static int do_depmod(int argc, char *argv[])
|
||||
CRIT("kmod_new(\"%s\", {NULL}) failed: %m\n", cfg.dirname);
|
||||
goto cmdline_failed;
|
||||
}
|
||||
kmod_set_log_priority(ctx, verbose);
|
||||
|
||||
log_setup_kmod_log(ctx, verbose);
|
||||
|
||||
err = depmod_init(&depmod, &cfg, ctx);
|
||||
if (err < 0) {
|
||||
|
10
tools/log.c
10
tools/log.c
@ -21,9 +21,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "libkmod.h"
|
||||
#include "kmod.h"
|
||||
|
||||
static bool log_use_syslog;
|
||||
static int log_priority = LOG_ERR;
|
||||
|
||||
void log_open(bool use_syslog)
|
||||
{
|
||||
@ -67,3 +69,11 @@ void log_kmod(void *data, int priority, const char *file, int line,
|
||||
free(str);
|
||||
(void)data;
|
||||
}
|
||||
|
||||
void log_setup_kmod_log(struct kmod_ctx *ctx, int priority)
|
||||
{
|
||||
log_priority = priority;
|
||||
|
||||
kmod_set_log_priority(ctx, log_priority);
|
||||
kmod_set_log_fn(ctx, log_kmod, NULL);
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ void log_close(void);
|
||||
void log_kmod(void *data, int priority, const char *file, int line,
|
||||
const char *fn, const char *format, va_list args);
|
||||
|
||||
struct kmod_ctx;
|
||||
void log_setup_kmod_log(struct kmod_ctx *ctx, int priority);
|
||||
|
||||
_always_inline_ const char *prio_to_str(int prio);
|
||||
|
||||
|
||||
|
@ -929,8 +929,7 @@ static int do_modprobe(int argc, char **orig_argv)
|
||||
goto done;
|
||||
}
|
||||
|
||||
kmod_set_log_priority(ctx, verbose);
|
||||
kmod_set_log_fn(ctx, log_kmod, NULL);
|
||||
log_setup_kmod_log(ctx, verbose);
|
||||
|
||||
kmod_load_resources(ctx);
|
||||
|
||||
|
@ -180,8 +180,7 @@ static int do_rmmod(int argc, char *argv[])
|
||||
goto done;
|
||||
}
|
||||
|
||||
kmod_set_log_priority(ctx, kmod_get_log_priority(ctx));
|
||||
kmod_set_log_fn(ctx, log_kmod, NULL);
|
||||
log_setup_kmod_log(ctx, verbose);
|
||||
|
||||
for (i = optind; i < argc; i++) {
|
||||
struct kmod_module *mod;
|
||||
|
Loading…
Reference in New Issue
Block a user