summaryrefslogtreecommitdiffstats
path: root/sinks
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-02-24 17:49:02 -0500
committerDmitri Pal <dpal@redhat.com>2009-02-24 17:49:02 -0500
commit78c5ff376dd37462fad9a2194e4ee4931dcbc473 (patch)
treecc99f4c16be76362f0b934cea688fd5a21d0a6de /sinks
parent27d15caafe401160fcc62829a3460a52cd45d429 (diff)
downloadelapi_draft-78c5ff376dd37462fad9a2194e4ee4931dcbc473.tar.gz
elapi_draft-78c5ff376dd37462fad9a2194e4ee4931dcbc473.tar.xz
elapi_draft-78c5ff376dd37462fad9a2194e4ee4931dcbc473.zip
Fixing unittest. Fininshing with submit to syslog.
Diffstat (limited to 'sinks')
-rw-r--r--sinks/syslog/elapi_sink_syslog.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/sinks/syslog/elapi_sink_syslog.c b/sinks/syslog/elapi_sink_syslog.c
index cd20597..c9931a8 100644
--- a/sinks/syslog/elapi_sink_syslog.c
+++ b/sinks/syslog/elapi_sink_syslog.c
@@ -12,8 +12,13 @@
/* FIXME - this should be taken from the config.h generated by autotools */
#define SYSLOG_RETRY 60
-#define syslog_audit_config "/etc/elapi/syslog_defaults.conf"
-#define syslog_audit_dir "/etc/elapi/syslog_defaults.d"
+/*
+#define SYSLOG_AUDIT_CONFIG "/etc/elapi/syslog_defaults.conf"
+#define SYSLOG_AUDIT_DIR "/etc/elapi/syslog_defaults.d"
+*/
+#define SYSLOG_AUDIT_CONFIG "/home/dpal/IPA/Code/elapi/etc/syslog_defaults.conf"
+#define SYSLOG_AUDIT_DIR "/home/dpal/IPA/Code/elapi/etc/syslog_defaults.d"
+
/* FIXME there is currently no code
* to make sure we do not call syslog functions from multiple dispatchers.
@@ -57,7 +62,7 @@ static int init_config(struct data_descriptor *dblock)
if(conf_data == (struct syslog_conf *)(NULL)) return errno;
/* Read configuration from the configuration file if any */
- (void)config_to_collection(dblock->appname, syslog_audit_config, syslog_audit_dir, &file_config);
+ (void)config_to_collection(dblock->appname, SYSLOG_AUDIT_CONFIG, SYSLOG_AUDIT_DIR, &file_config);
conf_data->option = LOG_ODELAY;
conf_data->facility = LOG_USER;
@@ -178,7 +183,7 @@ static int syslog_sink_format(struct data_descriptor *dblock,struct collection_i
{
struct syslog_event *event_storage;
struct syslog_conf *config;
-
+ struct collection_item *item;
int error = EOK;
DEBUG_STRING("syslog_sink_format","Entry");
@@ -190,9 +195,17 @@ static int syslog_sink_format(struct data_descriptor *dblock,struct collection_i
event_storage->priority = config->level | config->facility;
- /* FIXME form priority here */
+ /* Get Priority */
+ error = get_item(event,"priority",ELAPI_TYPE_INTEGER,ELAPI_TRAVERSE_ONELEVEL, &item);
+ if(error) {
+ DEBUG_NUMBER("Failed to get item from collection",error);
+ /* Fall through */
+ } else if((item != (struct collection_item *)(NULL)) &&
+ (item->type == ELAPI_TYPE_INTEGER))
+ event_storage->priority = *((int *)(item->data));
+
-
+ /* FIXME */
/* Traverse collection */
@@ -256,18 +269,16 @@ static void syslog_sink_close(struct data_descriptor *dblock)
static int syslog_sink_submit(struct data_descriptor *dblock)
{
struct syslog_event *event_storage;
- struct syslog_conf *config;
DEBUG_STRING("syslog_sink_submit","Entry");
DEBUG_NUMBER("DBLOCK in submit",dblock);
DEBUG_NUMBER("internal data in submit",dblock->internal_data);
event_storage = (struct syslog_event *)(dblock->internal_data);
- config = (struct syslog_conf *)(dblock->config);
-
+
DEBUG_STRING("OUTPUT:",event_storage->sd.buffer);
- fprintf(stderr,"%s %d %s\n",config->ident, event_storage->priority, event_storage->sd.buffer);
+ syslog(event_storage->priority, "%s", event_storage->sd.buffer);
syslog_sink_cleanup(dblock);