1 /* 2 ** Logging framework. 3 ** 4 ** Copyright (C) 2014 Michael Smith <msmith@icecast.org>, 5 ** Ralph Giles <giles@xiph.org>, 6 ** Ed "oddsock" Zaleski <oddsock@xiph.org>, 7 ** Karl Heyes <karl@xiph.org>, 8 ** Jack Moffitt <jack@icecast.org>, 9 ** Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>, 10 ** Thomas Ruecker <thomas@ruecker.fi> 11 ** 12 ** This library is free software; you can redistribute it and/or 13 ** modify it under the terms of the GNU Library General Public 14 ** License as published by the Free Software Foundation; either 15 ** version 2 of the License, or (at your option) any later version. 16 ** 17 ** This library is distributed in the hope that it will be useful, 18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 ** Library General Public License for more details. 21 ** 22 ** You should have received a copy of the GNU Library General Public 23 ** License along with this library; if not, write to the 24 ** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 25 ** Boston, MA 02110-1301, USA. 26 ** 27 */ 28 29 #ifndef __LOG_H__ 30 #define __LOG_H__ 31 32 #include <stdio.h> 33 34 #define LOG_EINSANE -1 35 #define LOG_ENOMORELOGS -2 36 #define LOG_ECANTOPEN -3 37 #define LOG_ENOTOPEN -4 38 #define LOG_ENOTIMPL -5 39 40 #ifdef _WIN32 41 #define IO_BUFFER_TYPE _IONBF 42 #else 43 #define IO_BUFFER_TYPE _IOLBF 44 #endif 45 46 void log_initialize(void); 47 int log_open_file(FILE *file); 48 int log_open(const char *filename); 49 int log_open_with_buffer(const char *filename, int size); 50 void log_set_level(int log_id, unsigned level); 51 void log_set_trigger(int id, unsigned trigger); 52 int log_set_filename(int id, const char *filename); 53 void log_set_lines_kept (int log_id, unsigned int count); 54 void log_contents (int log_id, char **_contents, unsigned int *_len); 55 int log_set_archive_timestamp(int id, int value); 56 void log_flush(int log_id); 57 void log_reopen(int log_id); 58 void log_close(int log_id); 59 void log_shutdown(void); 60 61 void log_write(int log_id, unsigned priority, const char *cat, const char *func, 62 const char *fmt, ...); 63 void log_write_direct(int log_id, const char *fmt, ...); 64 65 #endif /* __LOG_H__ */ 66