diff options
-rw-r--r-- | dbus-manager.c | 51 | ||||
-rw-r--r-- | log.c | 8 | ||||
-rw-r--r-- | log.h | 3 |
3 files changed, 60 insertions, 2 deletions
diff --git a/dbus-manager.c b/dbus-manager.c index 2323260dbb..a8661bace3 100644 --- a/dbus-manager.c +++ b/dbus-manager.c @@ -66,6 +66,11 @@ " <arg name=\"id\" type=\"u\"/>" \ " <arg name=\"job\" type=\"o\"/>" \ " </signal>" \ + " <property name=\"Version\" type=\"s\" access=\"read\"/>" \ + " <property name=\"RunningAs\" type=\"s\" access=\"read\"/>" \ + " <property name=\"BootTimestamp\" type=\"t\" access=\"read\"/>" \ + " <property name=\"LogLevel\" type=\"s\" access=\"readwrite\"/>" \ + " <property name=\"LogTarget\" type=\"s\" access=\"readwrite\"/>" \ " </interface>" \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE @@ -73,9 +78,51 @@ #define INTROSPECTION_END \ "</node>" +DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs); + +static int bus_manager_append_log_target(Manager *m, DBusMessageIter *i, const char *property, void *data) { + const char *t; + + assert(m); + assert(i); + assert(property); + + t = log_target_to_string(log_get_target()); + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t)) + return -ENOMEM; + + return 0; +} + +static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const char *property, void *data) { + const char *t; + + assert(m); + assert(i); + assert(property); + + t = log_level_to_string(log_get_max_level()); + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t)) + return -ENOMEM; + + return 0; +} + static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) { - int r; Manager *m = data; + + const BusProperty properties[] = { + { "org.freedesktop.systemd1", "Version", bus_property_append_string, "s", PACKAGE_VERSION }, + { "org.freedesktop.systemd1", "RunningAs", bus_manager_append_running_as, "s", &m->running_as }, + { "org.freedesktop.systemd1", "BootTimestamp", bus_property_append_uint64, "t", &m->boot_timestamp }, + { "org.freedesktop.systemd1", "LogLevel", bus_manager_append_log_level, "s", NULL }, + { "org.freedesktop.systemd1", "LogTarget", bus_manager_append_log_target, "s", NULL }, + { NULL, NULL, NULL, NULL, NULL } + }; + + int r; DBusError error; DBusMessage *reply = NULL; char * path = NULL; @@ -422,7 +469,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection free(introspection); } else - return bus_default_message_handler(m, message, NULL, NULL); + return bus_default_message_handler(m, message, NULL, properties); free(path); @@ -313,6 +313,14 @@ void log_parse_environment(void) { log_warning("Failed to parse log level %s. Ignoring.", e); } +LogTarget log_get_target(void) { + return log_target; +} + +int log_get_max_level(void) { + return log_max_level; +} + static const char *const log_target_table[] = { [LOG_TARGET_CONSOLE] = "console", [LOG_TARGET_SYSLOG] = "syslog", @@ -40,6 +40,9 @@ void log_set_max_level(int level); int log_set_target_from_string(const char *e); int log_set_max_level_from_string(const char *e); +LogTarget log_get_target(void); +int log_get_max_level(void); + void log_close_kmsg(void); int log_open_kmsg(void); void log_close_syslog(void); |