2006-06-26 00:48:02 +00:00
|
|
|
/*
|
|
|
|
include/proto/log.h
|
|
|
|
This file contains definitions of log-related functions, structures,
|
|
|
|
and macros.
|
|
|
|
|
2008-07-14 22:22:45 +00:00
|
|
|
Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation, version 2.1
|
|
|
|
exclusively.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PROTO_LOG_H
|
|
|
|
#define _PROTO_LOG_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
|
2006-06-29 16:54:54 +00:00
|
|
|
#include <common/config.h>
|
2007-05-13 19:36:56 +00:00
|
|
|
#include <common/memory.h>
|
2017-06-02 14:20:16 +00:00
|
|
|
#include <common/hathreads.h>
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
#include <types/log.h>
|
|
|
|
#include <types/proxy.h>
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
#include <types/stream.h>
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2018-09-05 12:58:15 +00:00
|
|
|
#include <proto/stream.h>
|
|
|
|
|
2017-11-24 16:34:44 +00:00
|
|
|
extern struct pool_head *pool_head_requri;
|
|
|
|
extern struct pool_head *pool_head_uniqueid;
|
2007-05-13 19:36:56 +00:00
|
|
|
|
2012-02-08 15:37:49 +00:00
|
|
|
extern char *log_format;
|
2012-02-27 10:23:10 +00:00
|
|
|
extern char default_tcp_log_format[];
|
2012-02-08 15:37:49 +00:00
|
|
|
extern char default_http_log_format[];
|
|
|
|
extern char clf_http_log_format[];
|
2015-09-22 14:05:32 +00:00
|
|
|
|
2015-09-25 17:17:44 +00:00
|
|
|
extern char default_rfc5424_sd_log_format[];
|
|
|
|
|
2018-11-12 06:25:28 +00:00
|
|
|
extern unsigned int dropped_logs;
|
|
|
|
|
2017-06-02 14:20:16 +00:00
|
|
|
extern THREAD_LOCAL char *logheader;
|
|
|
|
extern THREAD_LOCAL char *logheader_rfc5424;
|
|
|
|
extern THREAD_LOCAL char *logline;
|
|
|
|
extern THREAD_LOCAL char *logline_rfc5424;
|
2012-02-08 15:37:49 +00:00
|
|
|
|
2012-02-27 10:23:10 +00:00
|
|
|
|
2017-07-26 13:33:35 +00:00
|
|
|
/* Initialize/Deinitialize log buffers used for syslog messages */
|
|
|
|
int init_log_buffers();
|
|
|
|
void deinit_log_buffers();
|
|
|
|
|
2016-02-12 12:23:03 +00:00
|
|
|
/*
|
|
|
|
* Builds a log line.
|
|
|
|
*/
|
2018-09-05 12:58:15 +00:00
|
|
|
int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format);
|
|
|
|
|
|
|
|
static inline int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format)
|
|
|
|
{
|
|
|
|
return sess_build_logline(strm_sess(s), s, dst, maxsize, list_format);
|
|
|
|
}
|
|
|
|
|
2012-03-12 11:46:41 +00:00
|
|
|
|
2012-02-27 10:23:10 +00:00
|
|
|
/*
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
* send a log for the stream when we have enough info about it.
|
2012-02-27 10:23:10 +00:00
|
|
|
* Will not log if the frontend has no log defined.
|
|
|
|
*/
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void strm_log(struct stream *s);
|
2018-09-05 17:51:10 +00:00
|
|
|
void sess_log(struct session *sess);
|
2012-02-27 10:23:10 +00:00
|
|
|
|
2012-02-08 15:37:49 +00:00
|
|
|
/*
|
|
|
|
* add to the logformat linked list
|
|
|
|
*/
|
2016-11-22 23:41:28 +00:00
|
|
|
int add_to_logformat_list(char *start, char *end, int type, struct list *list_format, char **err);
|
2012-02-08 15:37:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse the log_format string and fill a linked list.
|
|
|
|
* Variable name are preceded by % and composed by characters [a-zA-Z0-9]* : %varname
|
|
|
|
* You can set arguments using { } : %{many arguments}varname
|
|
|
|
*/
|
2016-11-22 23:41:28 +00:00
|
|
|
int parse_logformat_string(const char *str, struct proxy *curproxy, struct list *list_format, int options, int cap, char **err);
|
2018-03-26 13:54:32 +00:00
|
|
|
|
|
|
|
/* Parse "log" keyword and update the linked list. */
|
|
|
|
int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err);
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
/*
|
|
|
|
* Displays the message on stderr with the date and pid. Overrides the quiet
|
|
|
|
* mode during startup.
|
|
|
|
*/
|
2017-11-24 15:50:31 +00:00
|
|
|
void ha_alert(const char *fmt, ...)
|
2009-04-03 10:01:47 +00:00
|
|
|
__attribute__ ((format(printf, 1, 2)));
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Displays the message on stderr with the date and pid.
|
|
|
|
*/
|
2017-11-24 15:50:31 +00:00
|
|
|
void ha_warning(const char *fmt, ...)
|
2009-04-03 10:01:47 +00:00
|
|
|
__attribute__ ((format(printf, 1, 2)));
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2018-11-21 17:04:52 +00:00
|
|
|
/*
|
|
|
|
* Displays the message on stderr with the date and pid.
|
|
|
|
*/
|
|
|
|
void ha_notice(const char *fmt, ...)
|
|
|
|
__attribute__ ((format(printf, 1, 2)));
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
/*
|
|
|
|
* Displays the message on <out> only if quiet mode is not set.
|
|
|
|
*/
|
2009-04-03 10:01:47 +00:00
|
|
|
void qfprintf(FILE *out, const char *fmt, ...)
|
|
|
|
__attribute__ ((format(printf, 2, 3)));
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2012-02-06 15:00:33 +00:00
|
|
|
/*
|
|
|
|
* This function adds a header to the message and sends the syslog message
|
|
|
|
* using a printf format string
|
|
|
|
*/
|
|
|
|
void send_log(struct proxy *p, int level, const char *format, ...)
|
|
|
|
__attribute__ ((format(printf, 3, 4)));
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
/*
|
|
|
|
* This function sends a syslog message to both log servers of a proxy,
|
|
|
|
* or to global log servers if the proxy is NULL.
|
|
|
|
* It also tries not to waste too much time computing the message header.
|
|
|
|
* It doesn't care about errors nor does it report them.
|
|
|
|
*/
|
|
|
|
|
2015-09-25 17:17:44 +00:00
|
|
|
void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd, size_t sd_size);
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2015-09-22 14:05:32 +00:00
|
|
|
/*
|
|
|
|
* returns log format for <fmt> or -1 if not found.
|
|
|
|
*/
|
|
|
|
int get_log_format(const char *fmt);
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
/*
|
|
|
|
* returns log level for <lev> or -1 if not found.
|
|
|
|
*/
|
|
|
|
int get_log_level(const char *lev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* returns log facility for <fac> or -1 if not found.
|
|
|
|
*/
|
|
|
|
int get_log_facility(const char *fac);
|
|
|
|
|
2012-02-08 15:38:44 +00:00
|
|
|
/*
|
|
|
|
* Write a string in the log string
|
2012-04-05 16:02:55 +00:00
|
|
|
* Take cares of quote options
|
2012-02-08 15:38:44 +00:00
|
|
|
*
|
2018-11-15 20:10:04 +00:00
|
|
|
* Return the address of the \0 character, or NULL on error
|
2012-02-08 15:38:44 +00:00
|
|
|
*/
|
2018-09-06 16:14:09 +00:00
|
|
|
char *lf_text_len(char *dst, const char *src, size_t len, size_t size, const struct logformat_node *node);
|
2012-04-05 16:02:55 +00:00
|
|
|
|
|
|
|
/*
|
2018-11-15 20:10:04 +00:00
|
|
|
* Write a IP address to the log string
|
2012-04-05 16:02:55 +00:00
|
|
|
* +X option write in hexadecimal notation, most signifant byte on the left
|
|
|
|
*/
|
2018-09-05 13:23:10 +00:00
|
|
|
char *lf_ip(char *dst, const struct sockaddr *sockaddr, size_t size, const struct logformat_node *node);
|
2012-04-05 16:02:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a port to the log
|
|
|
|
* +X option write in hexadecimal notation, most signifant byte on the left
|
|
|
|
*/
|
2018-09-05 13:23:10 +00:00
|
|
|
char *lf_port(char *dst, const struct sockaddr *sockaddr, size_t size, const struct logformat_node *node);
|
2012-04-05 16:02:55 +00:00
|
|
|
|
2012-02-08 15:38:44 +00:00
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
#endif /* _PROTO_LOG_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|