summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-02-26 16:36:49 -0500
committerDmitri Pal <dpal@redhat.com>2009-02-26 16:36:49 -0500
commitc20626a18afc1545f1fbc58907529ba743bb0843 (patch)
tree6a264795cec3d3f9b26e07a097b7dd731b7f0691
parent8fb404ff3d803964764452f7e027ded5bf1d85b3 (diff)
downloadelapi_draft-c20626a18afc1545f1fbc58907529ba743bb0843.tar.gz
elapi_draft-c20626a18afc1545f1fbc58907529ba743bb0843.tar.xz
elapi_draft-c20626a18afc1545f1fbc58907529ba743bb0843.zip
Added missing files and removed dups.
-rw-r--r--dispatcher/elapi_api.c115
-rw-r--r--etc/file_defaults.d/my_app1.conf~8
-rw-r--r--etc/file_defaults.d/my_app2.conf~17
3 files changed, 115 insertions, 25 deletions
diff --git a/dispatcher/elapi_api.c b/dispatcher/elapi_api.c
new file mode 100644
index 0000000..b89ac7d
--- /dev/null
+++ b/dispatcher/elapi_api.c
@@ -0,0 +1,115 @@
+/*
+ ELAPI
+
+ Module implements high level API for logging events
+
+ Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <dlfcn.h>
+#include "elapi_debug.h"
+#include "elapi_dispatcher.h"
+#include "elapi_collection.h"
+#include "elapi_sink.h"
+
+const char event_name[] = "event";
+
+/* Pointer to default global dispatcher */
+struct dispatcher_handle *global_dispatcher = (struct dispatcher_handle *)(NULL);
+
+
+/* Function to open audit using default routing functions */
+/* If appname is NULL - uses module name */
+int open_audit(const char *appname, char **desired_sinks)
+{
+ int error;
+
+ DEBUG_STRING("open_audit","Entry");
+
+ error = create_audit_dispatcher(&global_dispatcher,appname,desired_sinks,NULL,NULL);
+
+ DEBUG_NUMBER("open_audit Exit:",error);
+ return error;
+}
+
+/* Function to open audit using custom routing function */
+int open_audit_with_router(const char *appname,
+ char **desired_sinks,
+ event_router_fn desired_router,
+ void *custom_data)
+{
+ int error;
+
+ DEBUG_STRING("open_audit_with_router","Entry");
+
+ error = create_audit_dispatcher(&global_dispatcher,appname,desired_sinks,desired_router,custom_data);
+
+ DEBUG_NUMBER("open_audit_with_router Exit:",error);
+ return error;
+}
+
+
+/* Get dispatcher if you want to add sink to a default deispatcher or do some advaced operations */
+struct dispatcher_handle *get_dispatcher(void)
+{
+ DEBUG_STRING("get_dispatcher was called.","Returning default dispatcher.");
+ return global_dispatcher;
+}
+
+/* Close audit */
+void close_audit(void)
+{
+ DEBUG_STRING("close_audit","Entry");
+
+ destroy_audit_dispatcher(global_dispatcher);
+
+ DEBUG_STRING("close_audit","Exit");
+}
+
+/* Creates collection with the timestamp already prepopulated */
+int create_event(struct collection_item **event,char *name)
+{
+ int error;
+ char *nm;
+
+ DEBUG_STRING("create_event","Entry");
+
+ if(name == NULL) nm = event_name;
+ else nm = name;
+
+ /* Construct collection and add timestamp */
+ if(((error = create_collection(event,nm)) != 0) ||
+ ((error = set_timestamp(*event,NULL,NULL)) !=0 )) {
+ DEBUG_NUMBER("Failed to create event:",error);
+ return error;
+ }
+
+ DEBUG_STRING("create_event Exit:","");
+ return EOK;
+
+}
+
+/* Log event */
+void log_event(char *format_string,struct collection_item *event)
+{
+ DEBUG_STRING("log_event","Entry");
+ log_audit_event(global_dispatcher, event, format_string);
+ DEBUG_STRING("log_event","Entry");
+}
diff --git a/etc/file_defaults.d/my_app1.conf~ b/etc/file_defaults.d/my_app1.conf~
deleted file mode 100644
index 33f860c..0000000
--- a/etc/file_defaults.d/my_app1.conf~
+++ /dev/null
@@ -1,8 +0,0 @@
-; This is the test application configuration
-; Log into the given file:
-
-file_name=/tmp/log1
-
-; Open once and keep open
-
-keep_open=1
diff --git a/etc/file_defaults.d/my_app2.conf~ b/etc/file_defaults.d/my_app2.conf~
deleted file mode 100644
index fe5846a..0000000
--- a/etc/file_defaults.d/my_app2.conf~
+++ /dev/null
@@ -1,17 +0,0 @@
-; This is the test application configuration
-; Identify myself as "TESTAPP"
-; See /usr/include/sys/syslog.h for more details
-
-identity="TESTAPP"
-
-; Default option is to include PID
-
-option = 1
-
-; Level is LOG_INFO.
-
-level = 6
-
-; Facility is LOG_AUTHPRIV (upper 28 bits) 10<<3
-
-facility = 80