[icinga-checkins] icinga.org: icinga-core/feature/exclude-with-regexp-3720: classic ui: log errors into cgi log (use_logging=1)

git at icinga.org git at icinga.org
Sat Jul 20 13:54:45 CEST 2013


Module: icinga-core
Branch: feature/exclude-with-regexp-3720
Commit: 74d3c379c6b526e8928009f4100c991fae181bc6
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=74d3c379c6b526e8928009f4100c991fae181bc6

Author: Michael Friedrich <Michael.Friedrich at netways.de>
Date:   Fri Jul  5 23:48:29 2013 +0200

classic ui: log errors into cgi log (use_logging=1)

since we already got the logit() stub in place, we just fake the core
logging, but reuse the cgi logging functionality, but only if
use_logging was set to 1 on cgi.cfg

more logging required though.

refs #4389

---

 Changelog      |    1 +
 cgi/cgiutils.c |   21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 0343aed..e297b1d 100644
--- a/Changelog
+++ b/Changelog
@@ -21,6 +21,7 @@ UPGRADE NOTES
 ENHANCEMENTS
 
 * classic ui: add display filter modification for status.cgi #852 - RB
+* classic ui: log errors into cgi log (use_logging=1) #4389 - MF
 
 * idoutils: add a table trimming option for 'downtime history' #3989 - MF
 
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index db0526c..4045758 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -234,13 +234,28 @@ int		cgi_log_rotation_method = LOG_ROTATION_NONE;
  * source-files once. A decent linker will make the call
  * a no-op anyway, so it's not a big issue
  */
-void logit(int data_type, int display, const char *fmt, ...) {
-	return;
-}
+
 int log_debug_info(int leve, int verbosity, const char *fmt, ...) {
 	return 0;
 }
 
+/*
+ * pipe all common logit calls into our cgi log file
+ * if enabled using 'use_logging'
+ */
+void logit(int data_type, int display, const char *fmt, ...) {
+	if (use_logging) {
+		va_list ap;
+		char *buffer = NULL;
+		va_start(ap, fmt);
+		if (vasprintf(&buffer, fmt, ap) > 0) {
+			write_to_cgi_log(buffer);
+			free(buffer);
+		}
+		va_end(ap);
+	}
+}
+
 /**********************************************************
  ***************** CLEANUP FUNCTIONS **********************
  **********************************************************/





More information about the icinga-checkins mailing list