summaryrefslogtreecommitdiff
path: root/src/include/tipidee/log.h
blob: bf3b812ecbf7c8125de269496e8c11926996ea9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* ISC license. */

#ifndef TIPIDEE_LOG_H
#define TIPIDEE_LOG_H

#include <stdint.h>

#include <skalibs/uint64.h>
#include <skalibs/strerr.h>
#include <skalibs/stralloc.h>

#include <tipidee/rql.h>
#include <tipidee/headers.h>

#define TIPIDEE_LOG_REQUEST 0x0001
#define TIPIDEE_LOG_REFERRER 0x0002
#define TIPIDEE_LOG_UA 0x0004
#define TIPIDEE_LOG_RESOURCE 0x0008
#define TIPIDEE_LOG_ANSWER 0x0010
#define TIPIDEE_LOG_SIZE 0x0020
#define TIPIDEE_LOG_START 0x0040
#define TIPIDEE_LOG_CLIENTIP 0x0080
#define TIPIDEE_LOG_CLIENTHOST 0x0100
#define TIPIDEE_LOG_HOSTASPREFIX 0x0200
#define TIPIDEE_LOG_DEBUG 0x0400

#define TIPIDEE_LOG_DEFAULT (TIPIDEE_LOG_REQUEST | TIPIDEE_LOG_ANSWER | TIPIDEE_LOG_SIZE)

typedef struct tipidee_resattr_s tipidee_resattr, *tipidee_resattr_ref ;
struct tipidee_resattr_s
{
  char const *content_type ;
  uint32_t iscgi : 1 ;
  uint32_t isnph : 1 ;
} ;
#define TIPIDEE_RESATTR_ZERO { .content_type = 0, .iscgi = 0, .isnph = 0 }

extern void tipidee_log_start (uint32_t, char const *, char const *) ;
extern void tipidee_log_exit (uint32_t, unsigned int) ;

extern void tipidee_log_request (uint32_t, tipidee_rql const *, tipidee_headers const *, stralloc *) ;
extern void tipidee_log_resource (uint32_t, tipidee_rql const *, char const *, tipidee_resattr const *, char const *) ;
extern void tipidee_log_answer (uint32_t, tipidee_rql const *, unsigned int, uint64_t) ;

#define tipidee_log_debug(v, ...) do { if ((v) & TIPIDEE_LOG_DEBUG) strerr_warn(PROG, ": debug: ", __VA_ARGS__) ; } while (0)

#endif