1 /* Icecast 2 * 3 * This program is distributed under the GNU General Public License, version 2. 4 * A copy of this license is included with this source. 5 * 6 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 7 * Michael Smith <msmith@xiph.org>, 8 * oddsock <oddsock@xiph.org>, 9 * Karl Heyes <karl@xiph.org> 10 * and others (see AUTHORS for details). 11 */ 12 13 #ifndef __LOGGING_H__ 14 #define __LOGGING_H__ 15 16 #include "cfgfile.h" 17 #include "log/log.h" 18 19 /* declare the global log descriptors */ 20 21 extern int errorlog; 22 extern int accesslog; 23 extern int playlistlog; 24 25 #ifdef _WIN32 26 #include <string.h> 27 #define __func__ strrchr (__FILE__, '\\') ? strrchr (__FILE__, '\\') + 1 : __FILE__ 28 #endif 29 30 /* 31 ** Variadic macros for logging 32 */ 33 34 #define ICECAST_LOG_ERROR(...) log_write(errorlog, 1, CATMODULE "/", __func__, __VA_ARGS__) 35 #define ICECAST_LOG_WARN(...) log_write(errorlog, 2, CATMODULE "/", __func__, __VA_ARGS__) 36 #define ICECAST_LOG_INFO(...) log_write(errorlog, 3, CATMODULE "/", __func__, __VA_ARGS__) 37 #define ICECAST_LOG_DEBUG(...) log_write(errorlog, 4, CATMODULE "/", __func__, __VA_ARGS__) 38 39 /* CATMODULE is the category or module that logging messages come from. 40 ** we set one here in cause someone forgets in the .c file. 41 */ 42 /*#define CATMODULE "unknown" 43 */ 44 45 /* this is the logging call to write entries to the access_log 46 ** the combined log format is: 47 ** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME] 48 ** ADDR = ip address of client 49 ** USER = username if authenticated 50 ** AUTH = auth type, not used, and set to "-" 51 ** DATE = date in "[30/Apr/2001:01:25:34 -0700]" format 52 ** REQUEST = request, ie "GET /live.ogg HTTP/1.0" 53 ** CODE = response code, ie, 200 or 404 54 ** BYTES = total bytes of data sent (other than headers) 55 ** REFERER = the refering URL 56 ** AGENT = the user agent 57 ** 58 ** for icecast, we add on extra field at the end, which will be 59 ** ignored by normal log parsers 60 ** 61 ** TIME = seconds that the connection lasted 62 ** 63 ** this allows you to get bitrates (BYTES / TIME) 64 ** and figure out exact times of connections 65 ** 66 ** it should be noted also that events are sent on client disconnect, 67 ** so the DATE is the timestamp of disconnection. DATE - TIME is the 68 ** time of connection. 69 */ 70 71 #define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z" 72 73 void logging_access(client_t *client); 74 void logging_playlist(const char *mount, const char *metadata, long listeners); 75 void restart_logging (ice_config_t *config); 76 void log_parse_failure (void *ctx, const char *fmt, ...); 77 78 #endif /* __LOGGING_H__ */ 79 80