aboutsummaryrefslogtreecommitdiffstats
path: root/Source/lib/utils/logger_manager.h
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-04-05 12:10:50 +0000
committerMartin Willi <martin@strongswan.org>2006-04-05 12:10:50 +0000
commit6862128151fb78f63685a8da5575783c426d64a7 (patch)
tree75920a6688ed5654fb917ecccc1e0e469480fd1f /Source/lib/utils/logger_manager.h
parent3dbbbf3e16366b0da33b29bbc1a4ba9a976e43a0 (diff)
downloadstrongswan-6862128151fb78f63685a8da5575783c426d64a7.tar.bz2
strongswan-6862128151fb78f63685a8da5575783c426d64a7.tar.xz
../svn-commit.tmp
Diffstat (limited to 'Source/lib/utils/logger_manager.h')
-rw-r--r--Source/lib/utils/logger_manager.h155
1 files changed, 155 insertions, 0 deletions
diff --git a/Source/lib/utils/logger_manager.h b/Source/lib/utils/logger_manager.h
new file mode 100644
index 000000000..bc8f0e62f
--- /dev/null
+++ b/Source/lib/utils/logger_manager.h
@@ -0,0 +1,155 @@
+/**
+ * @file logger_manager.h
+ *
+ * @brief Interface of logger_manager_t.
+ *
+ */
+
+/*
+ * Copyright (C) 2005 Jan Hutter, Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+#ifndef LOGGER_MANAGER_H_
+#define LOGGER_MANAGER_H_
+
+#include <pthread.h>
+
+#include <utils/logger.h>
+
+
+typedef enum logger_context_t logger_context_t;
+
+/**
+ * @brief Context of a specific logger.
+ *
+ * @ingroup utils
+ */
+enum logger_context_t {
+ ALL_LOGGERS = -1,
+ PARSER = 0,
+ GENERATOR,
+ IKE_SA,
+ IKE_SA_MANAGER,
+ CHILD_SA,
+ MESSAGE,
+ THREAD_POOL,
+ WORKER,
+ SCHEDULER,
+ SENDER,
+ RECEIVER,
+ SOCKET,
+ TESTER,
+ DAEMON,
+ CONFIG,
+ ENCRYPTION_PAYLOAD,
+ PAYLOAD,
+ DER_DECODER,
+ DER_ENCODER,
+ LOGGER_CONTEXT_ROOF,
+};
+
+
+typedef struct logger_manager_t logger_manager_t;
+
+/**
+ * @brief Class to manage logger_t objects.
+ *
+ * The logger manager manages all logger_t object in a list and
+ * allows their manipulation. Via a logger_context_t, the loglevel
+ * of a specific logging type can be adjusted at runtime.
+ *
+ * @b Constructors:
+ * - logger_manager_create()
+ *
+ * @see logger_t
+ *
+ * @ingroup utils
+ */
+struct logger_manager_t {
+
+ /**
+ * @brief Gets a logger_t object for a specific logger context.
+ *
+ * @param this logger_manager_t object
+ * @param context logger_context to use the logger for
+ * @param name name for the new logger. Context name is already included
+ * and has not to be specified (so NULL is allowed)
+ * @return logger_t object
+ */
+ logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
+
+ /**
+ * @brief Returns the set log_level of a specific context.
+ *
+ * @param this calling object
+ * @param context context to check level
+ * @return log_level for the given logger_context
+ */
+ log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
+
+ /**
+ * @brief Enables a logger level of a specific context.
+ *
+ * Use context ALL_LOGGERS to manipulate all loggers.
+ *
+ * @param this calling object
+ * @param context context to set level
+ * @param log_level logger level to eanble
+ */
+ void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
+
+ /**
+ * @brief Disables a logger level of a specific context.
+ *
+ * Use context ALL_LOGGERS to manipulate all loggers.
+ *
+ * @param this calling object
+ * @param context context to set level
+ * @param log_level logger level to disable
+ */
+ void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
+
+ /**
+ * @brief Sets the output of a logger.
+ *
+ * Use context ALL_LOGGERS to redirect all loggers.
+ *
+ * @param this calling object
+ * @param context context to set output
+ * @param log_level logger level to disable
+ */
+ void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
+
+ /**
+ * @brief Destroys a logger_manager_t object.
+ *
+ * All managed logger_t objects are also destroyed.
+ *
+ * @param this logger_manager_t object
+ */
+ void (*destroy) (logger_manager_t *this);
+};
+
+/**
+ * @brief Constructor to create a logger_manager_t object.
+ *
+ * @param default_log_level default log level for all context
+ * @return logger_manager_t object
+ *
+ * @ingroup utils
+ */
+logger_manager_t *logger_manager_create(log_level_t default_log_level);
+
+
+#endif /*LOGGER_MANAGER_H_*/