blob: 2cf114b7db6f0ba5cbf523eaa48051f1c4c7248d [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/proto/log.h
3 This file contains definitions of log-related functions, structures,
4 and macros.
5
Willy Tarreauec6c5df2008-07-15 00:22:45 +02006 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02007
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation, version 2.1
11 exclusively.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23#ifndef _PROTO_LOG_H
24#define _PROTO_LOG_H
25
26#include <stdio.h>
27#include <syslog.h>
28
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020029#include <common/config.h>
Willy Tarreau332f8bf2007-05-13 21:36:56 +020030#include <common/memory.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#include <types/log.h>
32#include <types/proxy.h>
33#include <types/session.h>
34
Willy Tarreau332f8bf2007-05-13 21:36:56 +020035extern struct pool_head *pool2_requri;
36
William Lallemand723b73a2012-02-08 16:37:49 +010037extern char *log_format;
38extern char default_http_log_format[];
39extern char clf_http_log_format[];
40
41/*
42 * Parse args in a logformat_var
43 */
44int parse_logformat_var_args(char *args, struct logformat_node *node);
45
46/*
47 * Parse a variable '%varname' or '%{args}varname' in logformat
48 *
49 */
50int parse_logformat_var(char *str, size_t len, struct proxy *curproxy);
51
52/*
53 * add to the logformat linked list
54 */
55void add_to_logformat_list(char *start, char *end, int type, struct proxy *curproxy);
56
57/*
58 * Parse the log_format string and fill a linked list.
59 * Variable name are preceded by % and composed by characters [a-zA-Z0-9]* : %varname
60 * You can set arguments using { } : %{many arguments}varname
61 */
62void parse_logformat_string(char *str, struct proxy *curproxy);
63
Willy Tarreaubaaee002006-06-26 02:48:02 +020064/*
65 * Displays the message on stderr with the date and pid. Overrides the quiet
66 * mode during startup.
67 */
Willy Tarreau40d25162009-04-03 12:01:47 +020068void Alert(const char *fmt, ...)
69 __attribute__ ((format(printf, 1, 2)));
Willy Tarreaubaaee002006-06-26 02:48:02 +020070
71/*
72 * Displays the message on stderr with the date and pid.
73 */
Willy Tarreau40d25162009-04-03 12:01:47 +020074void Warning(const char *fmt, ...)
75 __attribute__ ((format(printf, 1, 2)));
Willy Tarreaubaaee002006-06-26 02:48:02 +020076
77/*
78 * Displays the message on <out> only if quiet mode is not set.
79 */
Willy Tarreau40d25162009-04-03 12:01:47 +020080void qfprintf(FILE *out, const char *fmt, ...)
81 __attribute__ ((format(printf, 2, 3)));
Willy Tarreaubaaee002006-06-26 02:48:02 +020082
William Lallemand2a4a44f2012-02-06 16:00:33 +010083/* generate the syslog header one time per second */
84char *hdr_log(char *dst);
85
86/*
87 * This function adds a header to the message and sends the syslog message
88 * using a printf format string
89 */
90void send_log(struct proxy *p, int level, const char *format, ...)
91 __attribute__ ((format(printf, 3, 4)));
92
Willy Tarreaubaaee002006-06-26 02:48:02 +020093/*
94 * This function sends a syslog message to both log servers of a proxy,
95 * or to global log servers if the proxy is NULL.
96 * It also tries not to waste too much time computing the message header.
97 * It doesn't care about errors nor does it report them.
98 */
Willy Tarreaubaaee002006-06-26 02:48:02 +020099
William Lallemand2a4a44f2012-02-06 16:00:33 +0100100void __send_log(struct proxy *p, int level, char *message, size_t size);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200101/*
102 * send a log for the session when we have enough info about it
103 */
Willy Tarreau42250582007-04-01 01:30:43 +0200104void tcp_sess_log(struct session *s);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200105
106/*
107 * returns log level for <lev> or -1 if not found.
108 */
109int get_log_level(const char *lev);
110
111/*
112 * returns log facility for <fac> or -1 if not found.
113 */
114int get_log_facility(const char *fac);
115
Willy Tarreaubaaee002006-06-26 02:48:02 +0200116#endif /* _PROTO_LOG_H */
117
118/*
119 * Local variables:
120 * c-indent-level: 8
121 * c-basic-offset: 8
122 * End:
123 */