]>
Commit | Line | Data |
---|---|---|
fe000966 DM |
1 | /* |
2 | Copyright (C) 2010 Proxmox Server Solutions GmbH | |
3 | ||
4 | This program is free software: you can redistribute it and/or modify | |
5 | it under the terms of the GNU Affero General Public License as published by | |
6 | the Free Software Foundation, either version 3 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU Affero General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Affero General Public License | |
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | Author: Dietmar Maurer <dietmar@proxmox.com> | |
18 | ||
19 | */ | |
20 | ||
21 | #ifndef _PVE_LOGGER_H_ | |
22 | #define _PVE_LOGGER_H_ | |
23 | ||
24 | #define CLOG_MAX_ENTRY_SIZE 4096 | |
25 | #define CLOG_DEFAULT_SIZE (8192*16) | |
26 | ||
27 | typedef struct clog_base clog_base_t; | |
28 | ||
29 | typedef struct clusterlog clusterlog_t; | |
30 | ||
31 | typedef struct { | |
32 | uint32_t prev; | |
33 | uint32_t next; | |
34 | uint32_t uid; /* unique id */ | |
35 | uint32_t time; | |
36 | uint64_t node_digest; | |
37 | uint64_t ident_digest; | |
38 | uint32_t pid; | |
39 | uint8_t priority; | |
40 | uint8_t node_len; | |
41 | uint8_t ident_len; | |
42 | uint8_t tag_len; | |
43 | uint32_t msg_len; | |
44 | char data[]; | |
45 | } clog_entry_t; | |
46 | ||
47 | clusterlog_t * | |
48 | clusterlog_new(void); | |
49 | ||
50 | void | |
51 | clusterlog_destroy(clusterlog_t *cl); | |
52 | ||
53 | gpointer | |
54 | clusterlog_get_state( | |
55 | clusterlog_t *cl, | |
56 | unsigned int *res_len); | |
57 | ||
58 | void | |
59 | clusterlog_add( | |
60 | clusterlog_t *cl, | |
61 | const char *ident, | |
62 | const char *tag, | |
63 | uint32_t pid, | |
64 | uint8_t priority, | |
65 | const gchar *format, | |
66 | ...) G_GNUC_PRINTF (6, 7); | |
67 | ||
68 | void | |
69 | clusterlog_insert( | |
70 | clusterlog_t *cl, | |
71 | const clog_entry_t *entry); | |
72 | ||
73 | void | |
74 | clusterlog_dump( | |
75 | clusterlog_t *cl, | |
76 | GString *str, | |
77 | const char *user, | |
78 | guint max_entries); | |
79 | ||
80 | clog_base_t * | |
81 | clusterlog_merge( | |
82 | clusterlog_t *cl, | |
83 | clog_base_t **clog, | |
84 | int count, | |
85 | int local_index); | |
86 | ||
87 | clog_base_t * | |
88 | clog_new(uint32_t size); | |
89 | ||
90 | uint32_t | |
91 | clog_size(clog_base_t *clog); | |
92 | ||
93 | void | |
94 | clog_dump(clog_base_t *clog); | |
95 | ||
96 | void | |
97 | clog_dump_json( | |
98 | clog_base_t *clog, | |
99 | GString *str, | |
100 | const char *ident, | |
101 | guint max_entries); | |
102 | ||
103 | clog_base_t * | |
104 | clog_sort(clog_base_t *clog); | |
105 | ||
106 | uint32_t | |
107 | clog_pack( | |
108 | clog_entry_t *buffer, | |
109 | const char *node, | |
110 | const char *ident, | |
111 | const char *tag, | |
112 | uint32_t pid, | |
113 | time_t logtime, | |
114 | uint8_t priority, | |
115 | const char *msg); | |
116 | ||
117 | uint32_t | |
118 | clog_entry_size(const clog_entry_t *entry); | |
119 | ||
120 | void | |
121 | clog_copy( | |
122 | clog_base_t *clog, | |
123 | const clog_entry_t *entry); | |
124 | ||
125 | #endif /* _PVE_LOGGER_H_ */ |