Annotation of embedaddon/strongswan/src/libcharon/bus/listeners/logger.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2012 Tobias Brunner
! 3: * HSR Hochschule fuer Technik Rapperswil
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: /**
! 17: * @defgroup logger logger
! 18: * @{ @ingroup listeners
! 19: */
! 20:
! 21: #ifndef LOGGER_H_
! 22: #define LOGGER_H_
! 23:
! 24: typedef struct logger_t logger_t;
! 25:
! 26: #include <bus/bus.h>
! 27:
! 28: /**
! 29: * Logger interface, listens for log events on the bus.
! 30: *
! 31: * Calls to bus_t.log() are handled separately from calls to other functions.
! 32: * Logger functions may be called concurrently by multiple threads. Also
! 33: * recursive calls are not prevented, loggers that may cause recursive log
! 34: * messages are responsible to avoid infinite loops.
! 35: *
! 36: * Both the log() and the vlog() methods are optional to implement. With many
! 37: * loggers, using log() may be faster as printf() format substitution is done
! 38: * only once for all loggers.
! 39: */
! 40: struct logger_t {
! 41:
! 42: /**
! 43: * Log a debugging message.
! 44: *
! 45: * @param group kind of the signal (up, down, rekeyed, ...)
! 46: * @param level verbosity level of the signal
! 47: * @param thread ID of the thread raised this signal
! 48: * @param ike_sa IKE_SA associated to the event
! 49: * @param message log message
! 50: */
! 51: void (*log)(logger_t *this, debug_t group, level_t level, int thread,
! 52: ike_sa_t *ike_sa, const char *message);
! 53:
! 54: /**
! 55: * Log a debugging message with a format string.
! 56: *
! 57: * @note Calls to bus_t.log() are handled separately from calls to
! 58: * other functions. This callback may be called concurrently by
! 59: * multiple threads. Also recursive calls are not prevented, loggers that
! 60: * may cause recursive log messages are responsible to avoid infinite loops.
! 61: *
! 62: * @param group kind of the signal (up, down, rekeyed, ...)
! 63: * @param level verbosity level of the signal
! 64: * @param thread ID of the thread raised this signal
! 65: * @param ike_sa IKE_SA associated to the event
! 66: * @param fmt log message format string
! 67: * @param args variable arguments to format string
! 68: */
! 69: void (*vlog)(logger_t *this, debug_t group, level_t level, int thread,
! 70: ike_sa_t *ike_sa, const char *fmt, va_list args);
! 71:
! 72: /**
! 73: * Get the desired log level for a debug group. This is called during
! 74: * registration.
! 75: *
! 76: * If the desired log levels have changed, re-register the logger with
! 77: * the bus.
! 78: *
! 79: * @param group debug group
! 80: * @return max level to log (0..4) or -1 for none (see debug.h)
! 81: */
! 82: level_t (*get_level)(logger_t *this, debug_t group);
! 83: };
! 84:
! 85: #endif /** LOGGER_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>