forked from douban/beansdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.h
59 lines (45 loc) · 1.46 KB
/
spec.h
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
48
49
50
51
52
53
54
55
56
57
58
59
/*
* This file is part of the zlog Library.
*
* Copyright (C) 2011 by Hardy Simpson <[email protected]>
*
* Licensed under the LGPL v2.1, see the file COPYING in base directory.
*/
#ifndef __zlog_spec_h
#define __zlog_spec_h
#include "event.h"
#include "buf.h"
#include "thread.h"
typedef struct zlog_spec_s zlog_spec_t;
/* write buf, according to each spec's Conversion Characters */
typedef int (*zlog_spec_write_fn) (zlog_spec_t * a_spec,
zlog_thread_t * a_thread,
zlog_buf_t * a_buf);
/* gen a_thread->msg or gen a_thread->path by using write_fn */
typedef int (*zlog_spec_gen_fn) (zlog_spec_t * a_spec,
zlog_thread_t * a_thread);
struct zlog_spec_s {
char *str;
int len;
char time_fmt[MAXLEN_CFG_LINE + 1];
int time_cache_index;
char mdc_key[MAXLEN_PATH + 1];
char print_fmt[MAXLEN_CFG_LINE + 1];
int left_adjust;
size_t max_width;
size_t min_width;
zlog_spec_write_fn write_buf;
zlog_spec_gen_fn gen_msg;
zlog_spec_gen_fn gen_path;
zlog_spec_gen_fn gen_archive_path;
};
zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_end, int * time_cache_count);
void zlog_spec_del(zlog_spec_t * a_spec);
void zlog_spec_profile(zlog_spec_t * a_spec, int flag);
#define zlog_spec_gen_msg(a_spec, a_thread) \
a_spec->gen_msg(a_spec, a_thread)
#define zlog_spec_gen_path(a_spec, a_thread) \
a_spec->gen_path(a_spec, a_thread)
#define zlog_spec_gen_archive_path(a_spec, a_thread) \
a_spec->gen_archive_path(a_spec, a_thread)
#endif