summaryrefslogtreecommitdiffstats
path: root/src/systemd-login.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-08-24 17:31:07 +0200
committerHans de Goede <hdegoede@redhat.com>2012-08-24 17:31:07 +0200
commit01f5a910ab2d66a3fb39403ea5ca4bc32a1e9631 (patch)
treead34098f1fa9f9efea0e268c8d9570ca328c3e4b /src/systemd-login.c
parentb2a77aa5169305d961d16046d043d3128893ecde (diff)
downloadvd_agent-01f5a910ab2d66a3fb39403ea5ca4bc32a1e9631.tar.gz
vd_agent-01f5a910ab2d66a3fb39403ea5ca4bc32a1e9631.tar.xz
vd_agent-01f5a910ab2d66a3fb39403ea5ca4bc32a1e9631.zip
Replace file-logging with syslog
This resolves: http://bugzilla.redhat.com/show_bug.cgi?id=747894 http://bugzilla.freedesktop.org/show_bug.cgi?id=49092 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src/systemd-login.c')
-rw-r--r--src/systemd-login.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/systemd-login.c b/src/systemd-login.c
index 277cb03..7907fe0 100644
--- a/src/systemd-login.c
+++ b/src/systemd-login.c
@@ -23,16 +23,16 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include <systemd/sd-login.h>
struct session_info {
- FILE *logfile;
int verbose;
sd_login_monitor *mon;
char *session;
};
-struct session_info *session_info_create(FILE *logfile, int verbose)
+struct session_info *session_info_create(int verbose)
{
struct session_info *si;
int r;
@@ -41,12 +41,11 @@ struct session_info *session_info_create(FILE *logfile, int verbose)
if (!si)
return NULL;
- si->logfile = logfile;
si->verbose = verbose;
r = sd_login_monitor_new("session", &si->mon);
if (r < 0) {
- fprintf(logfile, "Error creating login monitor: %s\n", strerror(-r));
+ syslog(LOG_ERR, "Error creating login monitor: %s", strerror(-r));
free(si);
return NULL;
}
@@ -75,12 +74,12 @@ const char *session_info_get_active_session(struct session_info *si)
r = sd_seat_get_active("seat0", &si->session, NULL);
/* ENOENT happens when a seat is switching from one session to another */
if (r < 0 && r != ENOENT)
- fprintf(si->logfile, "Error getting active session: %s\n",
+ syslog(LOG_ERR, "Error getting active session: %s",
strerror(-r));
if (si->verbose && si->session &&
(!old_session || strcmp(old_session, si->session)))
- fprintf(si->logfile, "Active session: %s\n", si->session);
+ syslog(LOG_INFO, "Active session: %s", si->session);
sd_login_monitor_flush(si->mon);
free(old_session);
@@ -95,10 +94,10 @@ char *session_info_session_for_pid(struct session_info *si, uint32_t pid)
r = sd_pid_get_session(pid, &session);
if (r < 0)
- fprintf(si->logfile, "Error getting session for pid %u: %s\n",
+ syslog(LOG_ERR, "Error getting session for pid %u: %s",
pid, strerror(-r));
else if (si->verbose)
- fprintf(si->logfile, "Session for pid %u: %s\n", pid, session);
+ syslog(LOG_INFO, "Session for pid %u: %s", pid, session);
return session;
}