summaryrefslogtreecommitdiff
path: root/src/libudev/libudev.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-11-14 20:46:11 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-11-14 20:46:11 -0500
commitdacd994fda3fadeb1fa01accbd37d61d0359e0ee (patch)
tree165d90b9b0c99689d76fd5f7ec129901c82d05ea /src/libudev/libudev.c
parentaec5d2b9b4159cab7357e311fd558790037cd04b (diff)
udev: switch to systemd logging functions
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/libudev.c')
-rw-r--r--src/libudev/libudev.c102
1 files changed, 21 insertions, 81 deletions
diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index f9a192b62b..3ce13d2f76 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -1,7 +1,7 @@
/***
This file is part of systemd.
- Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
+ Copyright 2008-2014 Kay Sievers <kay@vrfy.org>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
@@ -50,41 +50,18 @@ struct udev {
int priority, const char *file, int line, const char *fn,
const char *format, va_list args);
void *userdata;
- struct udev_list properties_list;
- int log_priority;
};
-void udev_log(struct udev *udev,
- int priority, const char *file, int line, const char *fn,
- const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- udev->log_fn(udev, priority, file, line, fn, format, args);
- va_end(args);
-}
-
-_printf_(6,0)
-static void log_stderr(struct udev *udev,
- int priority, const char *file, int line, const char *fn,
- const char *format, va_list args)
-{
- fprintf(stderr, "libudev: %s: ", fn);
- vfprintf(stderr, format, args);
-}
-
/**
* udev_get_userdata:
* @udev: udev library context
*
* Retrieve stored data pointer from library context. This might be useful
- * to access from callbacks like a custom log function.
+ * to access from callbacks.
*
* Returns: stored userdata
**/
-_public_ void *udev_get_userdata(struct udev *udev)
-{
+_public_ void *udev_get_userdata(struct udev *udev) {
if (udev == NULL)
return NULL;
return udev->userdata;
@@ -97,8 +74,7 @@ _public_ void *udev_get_userdata(struct udev *udev)
*
* Store custom @userdata in the library context.
**/
-_public_ void udev_set_userdata(struct udev *udev, void *userdata)
-{
+_public_ void udev_set_userdata(struct udev *udev, void *userdata) {
if (udev == NULL)
return;
udev->userdata = userdata;
@@ -115,8 +91,7 @@ _public_ void udev_set_userdata(struct udev *udev, void *userdata)
*
* Returns: a new udev library context
**/
-_public_ struct udev *udev_new(void)
-{
+_public_ struct udev *udev_new(void) {
struct udev *udev;
_cleanup_fclose_ FILE *f = NULL;
@@ -124,9 +99,6 @@ _public_ struct udev *udev_new(void)
if (udev == NULL)
return NULL;
udev->refcount = 1;
- udev->log_fn = log_stderr;
- udev->log_priority = LOG_INFO;
- udev_list_init(udev, &udev->properties_list, true);
f = fopen( UDEV_CONF_FILE, "re");
if (f != NULL) {
@@ -152,7 +124,7 @@ _public_ struct udev *udev_new(void)
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
- udev_err(udev, UDEV_CONF_FILE ":%u: missing assignment, skipping line.\n", line_nr);
+ log_debug(UDEV_CONF_FILE ":%u: missing assignment, skipping line.\n", line_nr);
continue;
}
val[0] = '\0';
@@ -184,7 +156,7 @@ _public_ struct udev *udev_new(void)
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
- udev_err(udev, UDEV_CONF_FILE ":%u: inconsistent quoting, skipping line.\n", line_nr);
+ log_debug(UDEV_CONF_FILE ":%u: inconsistent quoting, skipping line.\n", line_nr);
continue;
}
val[len-1] = '\0';
@@ -196,9 +168,9 @@ _public_ struct udev *udev_new(void)
prio = util_log_priority(val);
if (prio < 0)
- udev_err(udev, "/etc/udev/udev.conf:%u: invalid log level '%s', ignoring.\n", line_nr, val);
+ log_debug("/etc/udev/udev.conf:%u: invalid log level '%s', ignoring.\n", line_nr, val);
else
- udev_set_log_priority(udev, prio);
+ log_set_max_level(prio);
continue;
}
}
@@ -215,8 +187,7 @@ _public_ struct udev *udev_new(void)
*
* Returns: the passed udev library context
**/
-_public_ struct udev *udev_ref(struct udev *udev)
-{
+_public_ struct udev *udev_ref(struct udev *udev) {
if (udev == NULL)
return NULL;
udev->refcount++;
@@ -232,14 +203,12 @@ _public_ struct udev *udev_ref(struct udev *udev)
*
* Returns: the passed udev library context if it has still an active reference, or #NULL otherwise.
**/
-_public_ struct udev *udev_unref(struct udev *udev)
-{
+_public_ struct udev *udev_unref(struct udev *udev) {
if (udev == NULL)
return NULL;
udev->refcount--;
if (udev->refcount > 0)
return udev;
- udev_list_cleanup(&udev->properties_list);
free(udev);
return NULL;
}
@@ -249,31 +218,25 @@ _public_ struct udev *udev_unref(struct udev *udev)
* @udev: udev library context
* @log_fn: function to be called for log messages
*
- * The built-in logging writes to stderr. It can be
- * overridden by a custom function, to plug log messages
- * into the users' log functionality.
+ * This function is deprecated.
*
**/
_public_ void udev_set_log_fn(struct udev *udev,
void (*log_fn)(struct udev *udev,
int priority, const char *file, int line, const char *fn,
- const char *format, va_list args))
-{
- udev->log_fn = log_fn;
- udev_dbg(udev, "custom log function %p registered\n", log_fn);
+ const char *format, va_list args)) {
+ return;
}
/**
* udev_get_log_priority:
* @udev: udev library context
*
- * The initial log level is read from the udev config file at startup.
+ * This function is deprecated.
*
- * Returns: the current log level
**/
-_public_ int udev_get_log_priority(struct udev *udev)
-{
- return udev->log_priority;
+_public_ int udev_get_log_priority(struct udev *udev) {
+ return log_get_max_level();
}
/**
@@ -281,32 +244,9 @@ _public_ int udev_get_log_priority(struct udev *udev)
* @udev: udev library context
* @priority: the new log priority
*
- * Set the log level. This value controls which messages are logged.
+ * This function is deprecated.
+ *
**/
-_public_ void udev_set_log_priority(struct udev *udev, int priority)
-{
- char num[32];
-
- udev->log_priority = priority;
- snprintf(num, sizeof(num), "%u", udev->log_priority);
- udev_add_property(udev, "UDEV_LOG", num);
-}
-
-struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value)
-{
- if (value == NULL) {
- struct udev_list_entry *list_entry;
-
- list_entry = udev_get_properties_list_entry(udev);
- list_entry = udev_list_entry_get_by_name(list_entry, key);
- if (list_entry != NULL)
- udev_list_entry_delete(list_entry);
- return NULL;
- }
- return udev_list_entry_add(&udev->properties_list, key, value);
-}
-
-struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev)
-{
- return udev_list_get_entry(&udev->properties_list);
+_public_ void udev_set_log_priority(struct udev *udev, int priority) {
+ log_set_max_level(priority);
}