summaryrefslogtreecommitdiffstats
path: root/src/journald
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-08-23 14:44:03 +0200
committerTomas Bzatek <tbzatek@redhat.com>2013-10-15 15:23:49 +0200
commit37bac7185803b743d52db24e2c724100f532f29b (patch)
tree37afe11d53cc506d304bc6ce8e929b4b91c114cd /src/journald
parentfa53e73b895c90c80361300abc9304596115d2d1 (diff)
downloadopenlmi-providers-37bac7185803b743d52db24e2c724100f532f29b.tar.gz
openlmi-providers-37bac7185803b743d52db24e2c724100f532f29b.tar.xz
openlmi-providers-37bac7185803b743d52db24e2c724100f532f29b.zip
journald: Use lmi logging infrastructure for error messages
Diffstat (limited to 'src/journald')
-rw-r--r--src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c3
-rw-r--r--src/journald/LMI_JournalLogRecordProvider.c4
-rw-r--r--src/journald/LMI_JournalMessageLogProvider.c1
-rw-r--r--src/journald/LMI_JournalRecordInLogProvider.c1
-rw-r--r--src/journald/instutil.c20
-rw-r--r--src/journald/journal.h1
6 files changed, 19 insertions, 11 deletions
diff --git a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
index 580424e..af68527 100644
--- a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
+++ b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
@@ -23,6 +23,8 @@
#include "ind_manager.h"
#include "instutil.h"
+#include "journal.h"
+#include <globals.h>
static const CMPIBroker* _cb = NULL;
@@ -31,6 +33,7 @@ static IMError im_err = IM_ERR_OK;
static void LMI_JournalLogRecordInstanceCreationIndicationInitialize()
{
+ lmi_init_logging(JOURNAL_CIM_LOG_NAME, _cb);
im = im_create_manager(ind_gather, ind_filter_cb, false, ind_watcher,
IM_IND_CREATION, _cb, &im_err);
}
diff --git a/src/journald/LMI_JournalLogRecordProvider.c b/src/journald/LMI_JournalLogRecordProvider.c
index 812b4d2..34a8f93 100644
--- a/src/journald/LMI_JournalLogRecordProvider.c
+++ b/src/journald/LMI_JournalLogRecordProvider.c
@@ -39,9 +39,11 @@ static void LMI_JournalLogRecordInitialize()
sd_journal *journal;
int r;
+ lmi_init_logging(JOURNAL_CIM_LOG_NAME, _cb);
+
r = sd_journal_open(&journal, 0);
if (r < 0) {
- fprintf(stderr, "Error opening journal: %s\n", strerror(-r));
+ error("Error opening journal: %s\n", strerror(-r));
return;
}
journal_iter = journal;
diff --git a/src/journald/LMI_JournalMessageLogProvider.c b/src/journald/LMI_JournalMessageLogProvider.c
index 1a1ab02..c4d9457 100644
--- a/src/journald/LMI_JournalMessageLogProvider.c
+++ b/src/journald/LMI_JournalMessageLogProvider.c
@@ -31,6 +31,7 @@ static const CMPIBroker* _cb = NULL;
static void LMI_JournalMessageLogInitialize()
{
+ lmi_init_logging(JOURNAL_CIM_LOG_NAME, _cb);
}
static CMPIStatus LMI_JournalMessageLogCleanup(
diff --git a/src/journald/LMI_JournalRecordInLogProvider.c b/src/journald/LMI_JournalRecordInLogProvider.c
index 2e5241f..a0046bf 100644
--- a/src/journald/LMI_JournalRecordInLogProvider.c
+++ b/src/journald/LMI_JournalRecordInLogProvider.c
@@ -31,6 +31,7 @@ static const CMPIBroker* _cb;
static void LMI_JournalRecordInLogInitialize()
{
+ lmi_init_logging(JOURNAL_CIM_LOG_NAME, _cb);
}
static CMPIStatus LMI_JournalRecordInLogCleanup(
diff --git a/src/journald/instutil.c b/src/journald/instutil.c
index c93a91e..fe6ab7a 100644
--- a/src/journald/instutil.c
+++ b/src/journald/instutil.c
@@ -125,13 +125,13 @@ void ind_init()
r = sd_journal_open(&journal, 0);
if (r < 0) {
- fprintf(stderr, "ind_init(): Error opening journal: %s\n", strerror(-r));
+ error("ind_init(): Error opening journal: %s\n", strerror(-r));
return;
}
r = sd_journal_seek_tail(journal);
if (r < 0) {
- fprintf(stderr, "ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r));
+ error("ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r));
sd_journal_close(journal);
return;
}
@@ -139,13 +139,13 @@ void ind_init()
/* need to position the marker one step before EOF or otherwise the next sd_journal_next() call will overflow to the beginning */
r = sd_journal_previous(journal);
if (r < 0) {
- fprintf(stderr, "ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r));
+ error("ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r));
sd_journal_close(journal);
return;
}
ind_journal = journal;
} else
- fprintf(stderr, "ind_init(): indications already initialized, possible bug in the code\n");
+ warn("ind_init(): indications already initialized, possible bug in the code\n");
}
void ind_destroy()
@@ -161,7 +161,7 @@ bool ind_watcher(void **data)
int r;
if (ind_journal == NULL) {
- fprintf(stderr, "ind_watcher(): indications have not been initialized yet or error occurred previously\n");
+ error("ind_watcher(): indications have not been initialized yet or error occurred previously\n");
return false;
}
@@ -176,11 +176,11 @@ bool ind_watcher(void **data)
r = sd_journal_wait(ind_journal, (uint64_t) -1);
}
if (r < 0) {
- fprintf(stderr, "ind_watcher(): Error while waiting for new record: %s\n", strerror(-r));
+ warn("ind_watcher(): Error while waiting for new record: %s\n", strerror(-r));
return false;
}
if (r == SD_JOURNAL_INVALIDATE) {
- fprintf(stderr, "ind_watcher(): Journal not valid, reopen needed\n");
+ warn("ind_watcher(): Journal not valid, reopen needed\n");
ind_destroy();
ind_init();
return false;
@@ -202,7 +202,7 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new
r = sd_journal_next(journal);
if (r < 0) {
- fprintf(stderr, "ind_gather(): Failed to iterate to next entry: %s\n", strerror(-r));
+ error("ind_gather(): Failed to iterate to next entry: %s\n", strerror(-r));
return false;
}
if (r == 0) {
@@ -214,13 +214,13 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new
LMI_JournalLogRecord_Init(&log_record, manager->broker, "root/cimv2");
r = create_LMI_JournalLogRecord(journal, &log_record, manager->broker);
if (r <= 0) {
- fprintf(stderr, "ind_gather(): Failed to create instance: %s\n", strerror(-r));
+ error("ind_gather(): Failed to create instance: %s\n", strerror(-r));
return false;
}
g_assert(new != NULL);
*new = LMI_JournalLogRecord_ToInstance(&log_record, &st);
- fprintf(stderr, " ind_gather(): new instance created\n");
+ debug(" ind_gather(): new instance created\n");
return true;
}
diff --git a/src/journald/journal.h b/src/journald/journal.h
index 6f999ec..b0365ca 100644
--- a/src/journald/journal.h
+++ b/src/journald/journal.h
@@ -23,6 +23,7 @@
#define JOURNAL_MESSAGE_LOG_NAME "Journal"
+#define JOURNAL_CIM_LOG_NAME "openlmi-journald" /* prefix used in debug messages */
/* Limit the number of LMI_JournalLogRecord instances enumerated */