Return to file_logger.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libcharon / bus / listeners |
1.1 misho 1: /* 1.1.1.2 ! misho 2: * Copyright (C) 2012-2020 Tobias Brunner 1.1 misho 3: * Copyright (C) 2006 Martin Willi 4: * HSR Hochschule fuer Technik Rapperswil 5: * 6: * This program is free software; you can redistribute it and/or modify it 7: * under the terms of the GNU General Public License as published by the 8: * Free Software Foundation; either version 2 of the License, or (at your 9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. 10: * 11: * This program is distributed in the hope that it will be useful, but 12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14: * for more details. 15: */ 16: 17: /** 18: * @defgroup file_logger file_logger 19: * @{ @ingroup listeners 20: */ 21: 22: #ifndef FILE_LOGGER_H_ 23: #define FILE_LOGGER_H_ 24: 25: #include <bus/listeners/logger.h> 26: 27: typedef struct file_logger_t file_logger_t; 28: 29: /** 30: * Logger to files which implements listener_t. 31: */ 32: struct file_logger_t { 33: 34: /** 35: * Implements the logger_t interface. 36: */ 37: logger_t logger; 38: 39: /** 40: * Set the loglevel for a debug group. 41: * 42: * @param group debug group to set 43: * @param level max level to log (0..4) 44: */ 45: void (*set_level) (file_logger_t *this, debug_t group, level_t level); 46: 47: /** 48: * Set options used by this logger 49: * 50: * @param time_format format of timestamp prefix, as in strftime(), cloned 51: * @param add_ms TRUE to add the number of milliseconds within the 52: * current second after the timestamp 53: * @param ike_name TRUE to prefix the name of the IKE_SA 1.1.1.2 ! misho 54: * @param log_level TRUE to include the log level in the message 1.1 misho 55: */ 56: void (*set_options) (file_logger_t *this, char *time_format, bool add_ms, 1.1.1.2 ! misho 57: bool ike_name, bool log_level); 1.1 misho 58: 59: /** 60: * Open (or reopen) the log file according to the given parameters 61: * 62: * @param flush_line TRUE to flush buffers after every logged line 63: * @param append FALSE to overwrite an existing file, TRUE to append 64: */ 65: void (*open) (file_logger_t *this, bool flush_line, bool append); 66: 67: /** 68: * Destroys a file_logger_t object. 69: */ 70: void (*destroy) (file_logger_t *this); 71: }; 72: 73: /** 74: * Constructor to create a file_logger_t object. 75: * 76: * The logger has to be opened via file_logger_t.open() before anything is 77: * logged. 78: * 79: * @param filename name of the log file (stderr and stdout are handled 80: * specially), cloned 81: * @return file_logger_t object 82: */ 83: file_logger_t *file_logger_create(char *filename); 84: 85: #endif /** FILE_LOGGER_H_ @}*/