stumpless 2.2.0
载入中...
搜索中...
未找到
entry.h
浏览该文件的文档.
1/* SPDX-License-Identifier: Apache-2.0 */
2
3/*
4 * Copyright 2018-2024 Joel E. Anderson
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
23#ifndef __STUMPLESS_ENTRY_H
24# define __STUMPLESS_ENTRY_H
25
26# include <stdarg.h>
27# include <stdbool.h>
28# include <stddef.h>
29# include <stumpless/config.h>
30# include <stumpless/element.h>
31# include <stumpless/facility.h>
32# include <stumpless/id.h>
33# include <stumpless/param.h>
34# include <stumpless/severity.h>
35
37#define STUMPLESS_MAX_PROCID_LENGTH 128
38
40#define STUMPLESS_MAX_HOSTNAME_LENGTH 255
41
43# define STUMPLESS_MAX_APP_NAME_LENGTH 48
44
46# define STUMPLESS_MAX_MSGID_LENGTH 32
47
48# ifdef __cplusplus
49extern "C" {
50# endif
51
93 int prival;
102 char *message;
113# ifdef STUMPLESS_WINDOWS_EVENT_LOG_TARGETS_SUPPORTED
115 void *wel_data;
116# endif
117# ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
122 void *mutex;
123# endif
124};
125
156struct stumpless_entry *
158 struct stumpless_element *element );
159
191struct stumpless_entry *
193 const char *name );
194
231struct stumpless_entry *
233 const char *element_name,
234 const char *param_name,
235 const char *param_value );
236
265struct stumpless_entry *
267
293void
295
317void
319
341void
343
371bool
373 const char *name );
374
401struct stumpless_element *
403 size_t index );
404
432struct stumpless_element *
434 const char *name );
435
459size_t
461
490size_t
492 const char *name );
493
525const char *
527
557
585const char *
587
625const char *
627
659const char *
661
689struct stumpless_param *
691 size_t element_index,
692 size_t param_index );
693
729struct stumpless_param *
731 const char *element_name,
732 const char *param_name );
733
768const char *
770 size_t element_index,
771 size_t param_index );
772
814const char *
816 const char *element_name,
817 const char *param_name );
818
842int
844
872const char *
874
904
947struct stumpless_entry *
949 enum stumpless_facility facility,
950 enum stumpless_severity severity,
951 const char *app_name,
952 const char *msgid,
953 const char *message,
954 ... );
955
986struct stumpless_entry *
988 enum stumpless_facility facility,
989 enum stumpless_severity severity,
990 const char *app_name,
991 const char *msgid,
992 const char *message );
993
1044struct stumpless_entry *
1046 enum stumpless_severity severity,
1047 const char *app_name,
1048 const char *msgid,
1049 const char *message,
1050 ... );
1051
1089struct stumpless_entry *
1091 enum stumpless_severity severity,
1092 const char *app_name,
1093 const char *msgid,
1094 const char *message );
1095
1135struct stumpless_entry *
1137 size_t index,
1138 struct stumpless_element *element );
1139
1170struct stumpless_entry *
1172 const char *app_name );
1173
1203struct stumpless_entry *
1205 enum stumpless_facility facility );
1206
1233struct stumpless_entry *
1235 const char *hostname );
1236
1276struct stumpless_entry *
1278 const char *message,
1279 ... );
1280
1310struct stumpless_entry *
1312 const char *message );
1313
1343struct stumpless_entry *
1345 const wchar_t *message );
1346
1380struct stumpless_entry *
1382 const char *msgid );
1383
1423struct stumpless_entry *
1425 size_t element_index,
1426 size_t param_index,
1427 struct stumpless_param *param );
1428
1461struct stumpless_entry *
1463 size_t element_index,
1464 size_t param_index,
1465 const char *value );
1466
1510struct stumpless_entry *
1512 const char *element_name,
1513 const char *param_name,
1514 const char *value );
1515
1548struct stumpless_entry *
1550 enum stumpless_facility facility,
1551 enum stumpless_severity severity );
1552
1580struct stumpless_entry *
1582 int prival );
1583
1610struct stumpless_entry *
1612
1642struct stumpless_entry *
1644 enum stumpless_severity severity );
1645
1671void
1673
1700void
1702
1742struct stumpless_entry *
1744 enum stumpless_facility facility,
1745 enum stumpless_severity severity,
1746 const char *app_name,
1747 const char *msgid,
1748 const char *message,
1749 va_list subs );
1750
1798struct stumpless_entry *
1800 enum stumpless_severity severity,
1801 const char *app_name,
1802 const char *msgid,
1803 const char *message,
1804 va_list subs );
1805
1840struct stumpless_entry *
1842 const char *message,
1843 va_list subs );
1844
1845# ifdef __cplusplus
1846} /* extern "C" */
1847# endif
1848#endif /* __STUMPLESS_ENTRY_H */
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
定义 config.h:31
Types and functions for creating and modifying elements.
struct stumpless_entry * stumpless_set_entry_hostname(struct stumpless_entry *entry, const char *hostname)
Sets the hostname of a given entry.
struct stumpless_entry * stumpless_set_entry_message_str_w(struct stumpless_entry *entry, const wchar_t *message)
Sets the message of a given entry.
struct stumpless_entry * stumpless_set_entry_message(struct stumpless_entry *entry, const char *message,...)
Sets the message of a given entry.
struct stumpless_entry * stumpless_copy_entry(const struct stumpless_entry *entry)
Creates a copy of an entry.
struct stumpless_entry * vstumpless_new_entry(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message, va_list subs)
Creates a new entry with the given parameters.
enum stumpless_facility stumpless_get_entry_facility(const struct stumpless_entry *entry)
Returns the facility code of the given entry.
struct stumpless_entry * stumpless_set_entry_param_by_index(struct stumpless_entry *entry, size_t element_index, size_t param_index, struct stumpless_param *param)
Puts the param in the element at the given index of an entry.
void stumpless_unload_entry_and_contents(const struct stumpless_entry *entry)
Unloads an entry as well as all elements that it contains.
const char * stumpless_get_entry_msgid(const struct stumpless_entry *entry)
Returns the msgid of the given entry.
struct stumpless_param * stumpless_get_entry_param_by_name(const struct stumpless_entry *entry, const char *element_name, const char *param_name)
Gets the first param from the element with the given name in an entry.
struct stumpless_entry * stumpless_add_new_param_to_entry(struct stumpless_entry *entry, const char *element_name, const char *param_name, const char *param_value)
Creates a new param and adds it to the given element in the given entry.
void stumpless_unload_entry_only(const struct stumpless_entry *entry)
Unloads an entry, freeing any allocated memory.
void stumpless_destroy_entry_only(const struct stumpless_entry *entry)
Destroys an entry, freeing any allocated memory.
struct stumpless_entry * stumpless_set_entry_param_value_by_name(struct stumpless_entry *entry, const char *element_name, const char *param_name, const char *value)
Sets the value of the first param in the named element an entry.
struct stumpless_entry * stumpless_set_entry_msgid(struct stumpless_entry *entry, const char *msgid)
Sets the msgid for an entry.
struct stumpless_element * stumpless_get_element_by_index(const struct stumpless_entry *entry, size_t index)
Returns the element at the given index in this Entry.
size_t stumpless_get_element_index(const struct stumpless_entry *entry, const char *name)
Returns the index of the element with the given name in this entry, if it is found.
#define STUMPLESS_MAX_HOSTNAME_LENGTH
The maximum length of a hostname, as specified by RFC 5424.
定义 entry.h:40
int stumpless_get_entry_prival(const struct stumpless_entry *entry)
Returns the prival of the given entry, as defined in RFC 5424.
struct stumpless_entry * stumpless_set_entry_priority(struct stumpless_entry *entry, enum stumpless_facility facility, enum stumpless_severity severity)
Sets the facility and severity of an entry.
bool stumpless_entry_has_element(const struct stumpless_entry *entry, const char *name)
True if the given entry has an element with the given name, false otherwise.
struct stumpless_element * stumpless_get_element_by_name(const struct stumpless_entry *entry, const char *name)
Returns the element with the given name in this entry, if it is found.
struct stumpless_entry * stumpless_add_element(struct stumpless_entry *entry, struct stumpless_element *element)
Adds an element to an entry.
size_t stumpless_get_element_count(const struct stumpless_entry *entry)
Returns the number of elements in the given entry.
const char * stumpless_get_entry_message(const struct stumpless_entry *entry)
Returns the message of the given entry.
struct stumpless_entry * stumpless_set_entry_param_value_by_index(struct stumpless_entry *entry, size_t element_index, size_t param_index, const char *value)
Sets the value of the param in the element at the given index of an entry.
struct stumpless_entry * stumpless_new_entry_str(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message)
Creates a new entry with the given characteristics.
void stumpless_destroy_entry(const struct stumpless_entry *entry)
An alias for stumpless_destroy_entry_and_contents.
struct stumpless_entry * stumpless_new_entry(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message,...)
Creates a new entry with the given characteristics.
struct stumpless_entry * stumpless_load_entry_str(struct stumpless_entry *entry, enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message)
Creates a new entry with the given characteristics.
struct stumpless_entry * stumpless_set_entry_facility(struct stumpless_entry *entry, enum stumpless_facility facility)
Sets the facility of an entry.
struct stumpless_entry * stumpless_set_entry_severity(struct stumpless_entry *entry, enum stumpless_severity severity)
Sets the severity of an entry.
const char * stumpless_get_entry_app_name(const struct stumpless_entry *entry)
Returns the app name of the given entry.
struct stumpless_entry * stumpless_set_entry_app_name(struct stumpless_entry *entry, const char *app_name)
Sets the app name for an entry.
struct stumpless_entry * vstumpless_set_entry_message(struct stumpless_entry *entry, const char *message, va_list subs)
Sets the message of a given entry.
const char * stumpless_get_entry_param_value_by_name(const struct stumpless_entry *entry, const char *element_name, const char *param_name)
Gets the value of the first param from the element with the given name in an entry.
struct stumpless_entry * stumpless_load_entry(struct stumpless_entry *entry, enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message,...)
Loads an entry struct with the given characteristics.
void stumpless_destroy_entry_and_contents(const struct stumpless_entry *entry)
Destroys an entry as well as all elements and params that it contains, freeing any allocated memory.
struct stumpless_entry * stumpless_set_entry_prival(struct stumpless_entry *entry, int prival)
Sets the prival of an entry, as defined in RFC 5424.
struct stumpless_param * stumpless_get_entry_param_by_index(const struct stumpless_entry *entry, size_t element_index, size_t param_index)
Gets the param from the element at the given index in an entry.
const char * stumpless_get_entry_hostname(const struct stumpless_entry *entry)
Returns the hostname of a given entry.
struct stumpless_entry * stumpless_set_element(struct stumpless_entry *entry, size_t index, struct stumpless_element *element)
Puts the element at the given index in the given entry.
#define STUMPLESS_MAX_PROCID_LENGTH
The maximum length of a procid, as specified by RFC 5424.
定义 entry.h:37
const char * stumpless_get_entry_procid(const struct stumpless_entry *entry)
Returns the procid of a given entry.
struct stumpless_entry * vstumpless_load_entry(struct stumpless_entry *entry, enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message, va_list subs)
Creates a new entry with the given parameters.
#define STUMPLESS_MAX_APP_NAME_LENGTH
The maximum length of an app name, as specified by RFC 5424.
定义 entry.h:43
const char * stumpless_get_entry_param_value_by_index(const struct stumpless_entry *entry, size_t element_index, size_t param_index)
Gets the value of the param from the element at the given index in an entry.
struct stumpless_entry * stumpless_set_entry_procid(struct stumpless_entry *entry, const char *procid)
Sets the procid of a given entry.
struct stumpless_entry * stumpless_add_new_element(struct stumpless_entry *entry, const char *name)
Creates a new element with the given name and adds it to this entry.
struct stumpless_entry * stumpless_set_entry_message_str(struct stumpless_entry *entry, const char *message)
Sets the message of a given entry.
#define STUMPLESS_MAX_MSGID_LENGTH
The maximum length of a msgid, as specified by RFC 5424.
定义 entry.h:46
enum stumpless_severity stumpless_get_entry_severity(const struct stumpless_entry *entry)
Returns the severity code of the given entry.
Facility codes for classifying log entries.
stumpless_facility
All possible facility codes available to log entries.
定义 facility.h:347
The identification for targets within the library.
void * stumpless_id_t
定义 id.h:30
Types and functions for creating and modifying params.
Severity codes for classifying log entries.
stumpless_severity
All possible severity codes available to log entries.
定义 severity.h:189
An element of structured data.
定义 element.h:93
char name[32+1]
The name of the element.
定义 element.h:114
A log entry.
定义 entry.h:60
void * mutex
A pointer to a mutex which protects all entry fields.
定义 entry.h:122
struct stumpless_element ** elements
An array holding the elements of this entry.
定义 entry.h:110
char hostname[255+1]
The hostname of this entry, as a NULL-terminated string.
定义 entry.h:81
char msgid[32+1]
The message id of this entry, as a NULL-terminated string.
定义 entry.h:106
size_t message_length
The length of the message in bytes, without the NULL terminator.
定义 entry.h:104
int prival
The prival of this entry.
定义 entry.h:93
char * message
The message of this entry, as a NULL-terminated string.
定义 entry.h:102
char procid[128+1]
The procid of this entry, as a NULL-terminated string.
定义 entry.h:68
size_t hostname_length
The length of the hostname of this entry (in bytes), without a NULL terminator.
定义 entry.h:88
size_t procid_length
The length of the procid of this entry (in bytes), without a NULL terminator.
定义 entry.h:75
void * wel_data
A pointer to a wel_data structure.
定义 entry.h:115
size_t app_name_length
The length of the app name, without the NULL terminator.
定义 entry.h:97
size_t element_count
The number of elements in this entry.
定义 entry.h:112
size_t msgid_length
The length of the message id, without the NULL terminator.
定义 entry.h:108
char app_name[48+1]
The app name of this entry, as a NULL-terminated string.
定义 entry.h:95
stumpless_id_t id
A unique identifier of this entry.
定义 entry.h:62
A parameter within a structured data element.
定义 param.h:93