2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
2020-10-03 04:44:37 -04:00
|
|
|
* Copyright 2014-2020, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2004-01-28 20:02:12 -05:00
|
|
|
*/
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#ifndef __LOGGING_H__
|
|
|
|
#define __LOGGING_H__
|
|
|
|
|
2014-12-02 16:50:57 -05:00
|
|
|
#include "common/log/log.h"
|
2003-02-02 09:32:21 -05:00
|
|
|
|
2018-06-17 08:28:38 -04:00
|
|
|
#include "icecasttypes.h"
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
/* declare the global log descriptors */
|
|
|
|
|
|
|
|
extern int errorlog;
|
|
|
|
extern int accesslog;
|
2004-11-15 23:04:02 -05:00
|
|
|
extern int playlistlog;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2002-02-06 20:04:09 -05:00
|
|
|
#ifdef _WIN32
|
2005-12-17 07:34:37 -05:00
|
|
|
#include <string.h>
|
|
|
|
#define __func__ strrchr (__FILE__, '\\') ? strrchr (__FILE__, '\\') + 1 : __FILE__
|
2002-02-06 20:04:09 -05:00
|
|
|
#endif
|
|
|
|
|
2014-12-07 19:39:57 -05:00
|
|
|
/* Log levels */
|
|
|
|
#define ICECAST_LOGLEVEL_ERROR 1
|
|
|
|
#define ICECAST_LOGLEVEL_WARN 2
|
|
|
|
#define ICECAST_LOGLEVEL_INFO 3
|
|
|
|
#define ICECAST_LOGLEVEL_DEBUG 4
|
|
|
|
|
2019-01-09 10:04:16 -05:00
|
|
|
/* Log flags */
|
|
|
|
#define ICECAST_LOGFLAG_NONE 0
|
|
|
|
#define ICECAST_LOGFLAG_DEVEL 1
|
|
|
|
|
2014-10-09 06:39:13 -04:00
|
|
|
/*
|
|
|
|
** Variadic macros for logging
|
|
|
|
*/
|
2002-08-03 04:16:52 -04:00
|
|
|
|
2019-01-09 10:04:16 -05:00
|
|
|
#define ICECAST_LOG(level,flags,...) log_write(errorlog, (level), CATMODULE "/", __func__, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define ICECAST_LOG_ERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, ICECAST_LOGFLAG_NONE, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_WARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, ICECAST_LOGFLAG_NONE, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_INFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, ICECAST_LOGFLAG_NONE, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_DEBUG(...) ICECAST_LOG(ICECAST_LOGLEVEL_DEBUG, ICECAST_LOGFLAG_NONE, __VA_ARGS__)
|
|
|
|
/* Currently only an alias for ICECAST_LOG_DEBUG() */
|
2019-01-09 10:39:55 -05:00
|
|
|
#ifdef DEVEL_LOGGING
|
2019-01-09 10:04:16 -05:00
|
|
|
#define ICECAST_LOG_DERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_DWARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_DINFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__)
|
|
|
|
#define ICECAST_LOG_DDEBUG(...) ICECAST_LOG(ICECAST_LOGLEVEL_DEBUG, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__)
|
2019-01-09 10:39:55 -05:00
|
|
|
#else
|
|
|
|
#define ICECAST_LOG_DERROR(...)
|
|
|
|
#define ICECAST_LOG_DWARN(...)
|
|
|
|
#define ICECAST_LOG_DINFO(...)
|
|
|
|
#define ICECAST_LOG_DDEBUG(...)
|
|
|
|
#endif
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
/* CATMODULE is the category or module that logging messages come from.
|
|
|
|
** we set one here in cause someone forgets in the .c file.
|
|
|
|
*/
|
|
|
|
/*#define CATMODULE "unknown"
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* this is the logging call to write entries to the access_log
|
|
|
|
** the combined log format is:
|
|
|
|
** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME]
|
|
|
|
** ADDR = ip address of client
|
|
|
|
** USER = username if authenticated
|
|
|
|
** AUTH = auth type, not used, and set to "-"
|
|
|
|
** DATE = date in "[30/Apr/2001:01:25:34 -0700]" format
|
|
|
|
** REQUEST = request, ie "GET /live.ogg HTTP/1.0"
|
|
|
|
** CODE = response code, ie, 200 or 404
|
|
|
|
** BYTES = total bytes of data sent (other than headers)
|
|
|
|
** REFERER = the refering URL
|
|
|
|
** AGENT = the user agent
|
|
|
|
**
|
|
|
|
** for icecast, we add on extra field at the end, which will be
|
|
|
|
** ignored by normal log parsers
|
|
|
|
**
|
|
|
|
** TIME = seconds that the connection lasted
|
|
|
|
**
|
|
|
|
** this allows you to get bitrates (BYTES / TIME)
|
|
|
|
** and figure out exact times of connections
|
|
|
|
**
|
|
|
|
** it should be noted also that events are sent on client disconnect,
|
|
|
|
** so the DATE is the timestamp of disconnection. DATE - TIME is the
|
|
|
|
** time of connection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z"
|
|
|
|
|
2020-10-15 04:57:20 -04:00
|
|
|
int logging_str2logid(const char *str);
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
void logging_access(client_t *client);
|
2005-05-24 21:43:33 -04:00
|
|
|
void logging_playlist(const char *mount, const char *metadata, long listeners);
|
2020-10-02 09:36:22 -04:00
|
|
|
void logging_mark(const char *username, const char *role);
|
2004-08-20 17:40:44 -04:00
|
|
|
void restart_logging (ice_config_t *config);
|
2005-08-16 12:56:24 -04:00
|
|
|
void log_parse_failure (void *ctx, const char *fmt, ...);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
#endif /* __LOGGING_H__ */
|