From c20626a18afc1545f1fbc58907529ba743bb0843 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 26 Feb 2009 16:36:49 -0500 Subject: Added missing files and removed dups. --- dispatcher/elapi_api.c | 115 ++++++++++++++++++++++++++++++++++++++ etc/file_defaults.d/my_app1.conf~ | 8 --- etc/file_defaults.d/my_app2.conf~ | 17 ------ 3 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 dispatcher/elapi_api.c delete mode 100644 etc/file_defaults.d/my_app1.conf~ delete mode 100644 etc/file_defaults.d/my_app2.conf~ 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 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 . +*/ + + +#include +#include +#include +#include +#include +#include +#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 -- cgit