| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #include <stdio.h> |
29 #include <stdio.h> |
| 30 #include <stdlib.h> |
30 #include <stdlib.h> |
| |
31 #include <inttypes.h> |
| 31 |
32 |
| 32 #include "addlog.h" |
33 #include "addlog.h" |
| 33 |
34 |
| 34 #include "../daemon/request.h" |
35 #include "../daemon/request.h" |
| 35 #include "../daemon/vserver.h" |
36 #include "../daemon/vserver.h" |
| 36 #include "../daemon/log.h" |
37 #include "../daemon/log.h" |
| 37 #include "../util/util.h" |
38 #include "../util/util.h" |
| |
39 #include "../util/io.h" |
| 38 |
40 |
| 39 int common_log(pblock *pb, Session *sn, Request *rq) { |
41 int common_log(pblock *pb, Session *sn, Request *rq) { |
| 40 NSAPIRequest *request = (NSAPIRequest*)rq; |
42 NSAPIRequest *request = (NSAPIRequest*)rq; |
| 41 VirtualServer *vs = request->vs; |
43 VirtualServer *vs = request->vs; |
| 42 AccessLog *log = vs->log; |
44 AccessLog *log = vs->log; |
| 57 char *time = ctime(&t); |
59 char *time = ctime(&t); |
| 58 char *req = pblock_findval("clf-request", rq->reqpb); |
60 char *req = pblock_findval("clf-request", rq->reqpb); |
| 59 |
61 |
| 60 // hack to get the content length |
62 // hack to get the content length |
| 61 // http_start_response should not modify the header names |
63 // http_start_response should not modify the header names |
| 62 char *len = pblock_findval("Content-length", rq->srvhdrs); |
64 int64_t len = httpstream_written(sn->csd); |
| 63 |
65 |
| 64 if(!ip) { |
66 if(!ip) { |
| 65 ip = "-"; |
67 ip = "-"; |
| 66 } |
68 } |
| 67 if(!user) { |
69 if(!user) { |
| 68 user = "-"; |
70 user = "-"; |
| 69 } |
|
| 70 if(!len) { |
|
| 71 len = "0"; |
|
| 72 } |
71 } |
| 73 |
72 |
| 74 // remove trailing line feed |
73 // remove trailing line feed |
| 75 cxstring tmstr = cx_str(time); |
74 cxstring tmstr = cx_str(time); |
| 76 if(tmstr.ptr[tmstr.length-1] == '\n') { |
75 if(tmstr.ptr[tmstr.length-1] == '\n') { |