Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 369 lines (302 sloc) 9.324 kb
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20b @alobbs Happy new year!
alobbs authored
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c39092 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-97f1...
alobbs authored
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
23 */
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
24
25 #include "common-internal.h"
26 #include "logger_ncsa.h"
27
28 #include <stdarg.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31 #include <fcntl.h>
32
33 #ifdef HAVE_SYS_TIME_H
34 # include <sys/time.h>
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
35 #else
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
36 # include <time.h>
37 #endif
38
39 #include "util.h"
40 #include "connection.h"
41 #include "connection-protected.h"
42 #include "header.h"
43 #include "header-protected.h"
44 #include "server.h"
45 #include "server-protected.h"
46 #include "connection.h"
47 #include "module.h"
48
49
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97f1-...
alobbs authored
50 /* Plug-in initialization
51 */
52 PLUGIN_INFO_LOGGER_EASIEST_INIT (ncsa);
53
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
54 /* Global stuff
55 */
56 static cherokee_buffer_t now;
57
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97f1-...
alobbs authored
58
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
59 ret_t
6392f7f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3045 5dc97367-97f1...
alobbs authored
60 cherokee_logger_ncsa_new (cherokee_logger_t **logger,
61 cherokee_virtual_server_t *vsrv,
62 cherokee_config_node_t *config)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
63 {
64 ret_t ret;
65 CHEROKEE_NEW_STRUCT (n, logger_ncsa);
529a35b git-svn-id: svn://cherokee-project.com/cherokee/trunk@1776 5dc97367-97f1...
taher authored
66
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
67 /* Init the base class object
68 */
4b729c5 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3057 5dc97367-97f1...
alobbs authored
69 cherokee_logger_init_base (LOGGER(n), PLUGIN_INFO_PTR(ncsa), config);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
70
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
71 MODULE(n)->init = (logger_func_init_t) cherokee_logger_ncsa_init;
72 MODULE(n)->free = (logger_func_free_t) cherokee_logger_ncsa_free;
529a35b git-svn-id: svn://cherokee-project.com/cherokee/trunk@1776 5dc97367-97f1...
taher authored
73
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
74 LOGGER(n)->flush = (logger_func_flush_t) cherokee_logger_ncsa_flush;
75 LOGGER(n)->reopen = (logger_func_reopen_t) cherokee_logger_ncsa_reopen;
76 LOGGER(n)->write_access = (logger_func_write_access_t) cherokee_logger_ncsa_write_access;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
77
6392f7f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3045 5dc97367-97f1...
alobbs authored
78 n->writer_access = NULL;
79
80 ret = cherokee_logger_ncsa_init_base (n, VSERVER(vsrv), config);
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
81 if (unlikely(ret < ret_ok)) {
075491e @alobbs "Possible memory leak. Dynamic memory stored in 'n' allocated through
alobbs authored
82 cherokee_logger_free (LOGGER(n));
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
83 return ret;
84 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
85
86 /* Return the object
87 */
88 *logger = LOGGER(n);
89 return ret_ok;
90 }
91
92
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
93 static void
94 bogotime_callback (void *param)
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
95 {
39b66dc @alobbs Loggers can now be configured to manage different time standards.
alobbs authored
96 struct tm *pnow_tm;
97 cherokee_logger_ncsa_t *logger = LOG_NCSA(param);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
98
39b66dc @alobbs Loggers can now be configured to manage different time standards.
alobbs authored
99 /* Choose between local and universal time
100 */
101 if (LOGGER(logger)->utc_time) {
102 pnow_tm = &cherokee_bogonow_tmgmt;
103 } else {
104 pnow_tm = &cherokee_bogonow_tmloc;
105 }
106
107 /* Render the string
108 */
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
109 cherokee_buffer_clean (&now);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
110 cherokee_buffer_add_va (&now,
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
111 " [%02d/%s/%d:%02d:%02d:%02d %c%02d%02d] \"",
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
112 pnow_tm->tm_mday,
113 month[pnow_tm->tm_mon],
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
114 1900 + pnow_tm->tm_year,
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
115 pnow_tm->tm_hour,
116 pnow_tm->tm_min,
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
117 pnow_tm->tm_sec,
118 (cherokee_bogonow_tzloc < 0) ? '-' : '+',
119 (int) (abs(cherokee_bogonow_tzloc) / 60),
120 (int) (abs(cherokee_bogonow_tzloc) % 60));
121 }
122
123
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
124 ret_t
6392f7f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3045 5dc97367-97f1...
alobbs authored
125 cherokee_logger_ncsa_init_base (cherokee_logger_ncsa_t *logger,
126 cherokee_virtual_server_t *vsrv,
127 cherokee_config_node_t *config)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
128 {
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
129 ret_t ret;
130 cherokee_config_node_t *subconf;
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
131 static int callback_init = 0;
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
132
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
133 /* Init the local buffers
134 */
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
135 cherokee_buffer_init (&logger->now_dtm);
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
136 cherokee_buffer_init (&logger->referer);
137 cherokee_buffer_init (&logger->useragent);
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
138 cherokee_buffer_ensure_size (&logger->now_dtm, 64);
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
139 cherokee_buffer_ensure_size (&logger->referer, 1024);
140 cherokee_buffer_ensure_size (&logger->useragent, 512);
141
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
142 /* Init the logger writer
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
143 */
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
144 ret = cherokee_config_node_get (config, "access", &subconf);
488e34a @alobbs Neither of these plug-ins was checking whether log writes were
alobbs authored
145 if (ret != ret_ok) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
146 LOG_CRITICAL (CHEROKEE_ERROR_LOGGER_NO_KEY, "access");
488e34a @alobbs Neither of these plug-ins was checking whether log writes were
alobbs authored
147 return ret_error;
148 }
809af53 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@343 5dc97367-97f1-...
alobbs authored
149
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
150 ret = cherokee_server_get_log_writer (VSERVER_SRV(vsrv), subconf, &logger->writer_access);
488e34a @alobbs Neither of these plug-ins was checking whether log writes were
alobbs authored
151 if (ret != ret_ok) {
152 return ret_error;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
153 }
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
154
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
155 /* Callback init
156 */
157 if (callback_init == 0) {
158 cherokee_buffer_init (&now);
39b66dc @alobbs Loggers can now be configured to manage different time standards.
alobbs authored
159 cherokee_bogotime_add_callback (bogotime_callback, logger, 1);
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
160 }
161
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
162 return ret_ok;
163 }
164
165
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
166 ret_t
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
167 cherokee_logger_ncsa_init (cherokee_logger_ncsa_t *logger)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
168 {
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
169 ret_t ret;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
170
6392f7f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3045 5dc97367-97f1...
alobbs authored
171 ret = cherokee_logger_writer_open (logger->writer_access);
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
172 if (ret != ret_ok) {
173 return ret;
174 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
175
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
176 return ret_ok;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
177 }
178
179
180 ret_t
181 cherokee_logger_ncsa_free (cherokee_logger_ncsa_t *logger)
182 {
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
183 cherokee_buffer_mrproper (&logger->now_dtm);
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
184 cherokee_buffer_mrproper (&logger->referer);
185 cherokee_buffer_mrproper (&logger->useragent);
186
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
187 return ret_ok;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
188 }
189
190
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
191 ret_t
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
192 cherokee_logger_ncsa_flush (cherokee_logger_ncsa_t *logger)
193 {
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
194 return cherokee_logger_writer_flush (logger->writer_access, false);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
195 }
196
197
198 static ret_t
a103da4 @alobbs Clean up.
alobbs authored
199 build_log_string (cherokee_logger_ncsa_t *logger,
200 cherokee_connection_t *cnt,
201 cherokee_buffer_t *buf)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
202 {
a103da4 @alobbs Clean up.
alobbs authored
203 ret_t ret;
204 const char *method;
205 const char *username;
206 const char *version;
207 cuint_t method_len = 0;
208 size_t username_len = 0;
209 cuint_t version_len = 0;
210 cherokee_buffer_t *referer = &logger->referer;
211 cherokee_buffer_t *useragent = &logger->useragent;
212 char ipaddr[CHE_INET_ADDRSTRLEN];
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
213
214 /* Look for the user
215 */
216 if (cnt->validator && !cherokee_buffer_is_empty (&cnt->validator->user)) {
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
217 username_len = cnt->validator->user.len;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
218 username = cnt->validator->user.buf;
219 } else {
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
220 username_len = 1;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
221 username = "-";
222 }
223
224 /* Get the method and version strings
225 */
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
226 ret = cherokee_http_method_to_string (cnt->header.method, &method, &method_len);
74cca38 @alobbs Some errors were not being logged in the log file.
alobbs authored
227 if (unlikely (ret < ret_ok)) {
228 method = "";
229 method_len = 0;
230 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
231
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
232 ret = cherokee_http_version_to_string (cnt->header.version, &version, &version_len);
74cca38 @alobbs Some errors were not being logged in the log file.
alobbs authored
233 if (unlikely (ret < ret_ok)) {
234 version = "";
235 version_len = 0;
236 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
237
238 /* Build the log string
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
239 *
240 * "%s - %s [%02d/%s/%d:%02d:%02d:%02d %c%02d%02d] \"%s %s %s\" %d "
241 * FMT_OFFSET
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
242 */
1dac32f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3052 5dc97367-97f1...
alobbs authored
243 if (cherokee_buffer_is_empty (&cnt->logger_real_ip)) {
244 memset (ipaddr, 0, sizeof(ipaddr));
245 cherokee_socket_ntop (&cnt->socket, ipaddr, sizeof(ipaddr)-1);
246 cherokee_buffer_add (buf, ipaddr, strlen(ipaddr));
247 } else {
248 cherokee_buffer_add_buffer (buf, &cnt->logger_real_ip);
249 }
250
251 cherokee_buffer_add_str (buf, " - ");
252 cherokee_buffer_add (buf, username, username_len);
253
802276c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@638 5dc97367-97f1-...
alobbs authored
254 /* " [date time] "
255 */
eda14f2 @alobbs Modifies the logger so it uses the bogotime callback mechanism.
alobbs authored
256 cherokee_buffer_add_buffer (buf, &now);
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
257 cherokee_buffer_add (buf, method, method_len);
802276c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@638 5dc97367-97f1-...
alobbs authored
258 cherokee_buffer_add_char (buf, ' ');
26ed7f3 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@3143 5dc97367-97f1...
skarcha authored
259
260 if (! cherokee_buffer_is_empty (&cnt->request_original)) {
261 cherokee_buffer_add_buffer (buf, &cnt->request_original);
a82df4d @skarcha Original query string is now saved, like original request, and added to ...
skarcha authored
262 if (! cherokee_buffer_is_empty (&cnt->query_string_original)) {
263 cherokee_buffer_add_char (buf, '?');
264 cherokee_buffer_add_buffer (buf, &cnt->query_string_original);
265 }
26ed7f3 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@3143 5dc97367-97f1...
skarcha authored
266 } else {
267 cherokee_buffer_add_buffer (buf, &cnt->request);
268 if (! cherokee_buffer_is_empty (&cnt->query_string)) {
269 cherokee_buffer_add_char (buf, '?');
270 cherokee_buffer_add_buffer (buf, &cnt->query_string);
271 }
56b070f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3049 5dc97367-97f1...
alobbs authored
272 }
26ed7f3 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@3143 5dc97367-97f1...
skarcha authored
273
802276c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@638 5dc97367-97f1-...
alobbs authored
274 cherokee_buffer_add_char (buf, ' ');
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
275 cherokee_buffer_add (buf, version, version_len);
276 cherokee_buffer_add_str (buf, "\" ");
6fe9dbe @alobbs When a custom error handler was triggered, the log entry showed a 200
alobbs authored
277
278 if (unlikely (cnt->error_internal_code != http_unset)) {
279 cherokee_buffer_add_long10 (buf, cnt->error_internal_code);
280 } else {
281 cherokee_buffer_add_long10 (buf, cnt->error_code);
282 }
283
3a55198 @alobbs This patch fixes a problem with the NCSA and Combined loggers. Under
alobbs authored
284 cherokee_buffer_add_char (buf, ' ');
285 cherokee_buffer_add_ullong10 (buf, cnt->tx);
9b334bc @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@405 5dc97367-97f1-...
alobbs authored
286
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
287 /* Look for the "combined" information
288 */
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
289 if (!logger->combined) {
802276c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@638 5dc97367-97f1-...
alobbs authored
290 cherokee_buffer_add_char (buf, '\n');
34523f0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@624 5dc97367-97f1-...
alobbs authored
291 return ret_ok;
292 }
293
294 /* "combined" information
295 */
a103da4 @alobbs Clean up.
alobbs authored
296 cherokee_buffer_clean (referer);
297 cherokee_buffer_clean (useragent);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
298
a103da4 @alobbs Clean up.
alobbs authored
299 cherokee_header_copy_known (&cnt->header, header_referer, referer);
300 cherokee_header_copy_known (&cnt->header, header_user_agent, useragent);
301 cherokee_buffer_ensure_addlen (buf, 8 + referer->len + referer->len);
302
303 if (referer->len > 0) {
304 cherokee_buffer_add_str (buf, " \"");
305 cherokee_buffer_add_buffer (buf, referer);
306 cherokee_buffer_add_str (buf, "\" \"");
307 } else {
308 cherokee_buffer_add_str (buf, " \"-\" \"");
309 }
310
311 if (useragent->len > 0) {
312 cherokee_buffer_add_buffer (buf, useragent);
9b334bc @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@405 5dc97367-97f1-...
alobbs authored
313 }
314
a103da4 @alobbs Clean up.
alobbs authored
315 cherokee_buffer_add_str (buf, "\"\n");
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
316 return ret_ok;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
317 }
318
319
320 ret_t
321 cherokee_logger_ncsa_write_access (cherokee_logger_ncsa_t *logger, cherokee_connection_t *cnt)
322 {
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
323 ret_t ret;
324 cherokee_buffer_t *log;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
325
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
326 /* Get the buffer
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
327 */
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
328 cherokee_logger_writer_get_buf (logger->writer_access, &log);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
329
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
330 /* Add the new string
331 */
332 ret = build_log_string (logger, cnt, log);
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
333 if (unlikely (ret != ret_ok)) {
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
334 goto error;
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
335 }
acc9fd3 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@610 5dc97367-97f1-...
alobbs authored
336
6be1e20 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1785 5dc97367-97f1...
alobbs authored
337 /* Flush buffer if full
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
338 */
6392f7f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3045 5dc97367-97f1...
alobbs authored
339 if (log->len < logger->writer_access->max_bufsize)
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
340 goto ok;
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
341
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
342 ret = cherokee_logger_writer_flush (logger->writer_access, true);
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
343 if (unlikely (ret != ret_ok)) {
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
344 goto error;
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
345 }
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
346
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
347 ok:
348 cherokee_logger_writer_release_buf (logger->writer_access);
6be1e20 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1785 5dc97367-97f1...
alobbs authored
349 return ret_ok;
905addb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3047 5dc97367-97f1...
alobbs authored
350
351 error:
352 cherokee_logger_writer_release_buf (logger->writer_access);
353 return ret_error;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
354 }
355
356
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
357 ret_t
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
358 cherokee_logger_ncsa_reopen (cherokee_logger_ncsa_t *logger)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
359 {
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
360 ret_t ret;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97f1-...
alobbs authored
361
c5fe3a4 @alobbs Errors are not longer written through the logger objects. They are
alobbs authored
362 ret = cherokee_logger_writer_reopen (logger->writer_access);
363 if (ret != ret_ok) {
364 return ret;
4d387f4 @alobbs This patch changes substantially the way in which errors and warnings
alobbs authored
365 }
bb452e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@618 5dc97367-97f1-...
alobbs authored
366
14ab3b2 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2387 5dc97367-97f1...
alobbs authored
367 return ret_ok;
368 }
Something went wrong with that request. Please try again.