Browse Source

Add forgotten callback file

git-svn-id: https://klish.googlecode.com/svn/trunk@491 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
35e50a622e
1 changed files with 29 additions and 0 deletions
  1. 29 0
      clish/callback_log.c

+ 29 - 0
clish/callback_log.c

@@ -0,0 +1,29 @@
+/*
+ * callback_log.c
+ *
+ * Callback hook to log users's commands
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+
+#include "internal.h"
+
+#define SYSLOG_IDENT "klish"
+#define SYSLOG_FACILITY LOG_LOCAL0
+
+/*--------------------------------------------------------- */
+int clish_log_callback(clish_context_t *context, const char *line,
+	int retcode)
+{
+	/* Initialization */
+	if (!line) {
+		openlog(SYSLOG_IDENT, LOG_PID, SYSLOG_FACILITY);
+		return 0;
+	}
+
+	/* Log the given line */
+	syslog(LOG_INFO, "%s : %d", line, retcode);
+
+	return 0;
+}