stumpless 2.2.0
|
A log entry. More...
#include <Entry.hpp>
Public Member Functions | |
Entry (Facility facility, Severity severity, const char *app_name, const char *msgid, const char *message,...) | |
Creates an Entry with the given properties. | |
Entry (struct stumpless_entry *entry) | |
Creates an Entry from a stumpless_entry struct. | |
Entry (const Entry &entry) | |
Creates an Entry as a copy of another Entry. | |
~Entry (void) | |
Destroys the Entry and frees any memory allocated for it. | |
Entry & | AddElement (Element &element) |
Adds an element to an entry. | |
Entry & | AddElement (Element *element) |
Adds an Element to this Entry. | |
Entry & | AddElement (const char *name) |
Creates a new Element and adds it to this Entry. | |
Entry & | AddParam (const char *element_name, const char *param_name, const char *param_value) |
Creates a new Param and adds it to the specified Element in this Entry. | |
const char * | GetAppName (void) |
Gets the app name from this Entry. | |
Element | GetElement (size_t index) |
Gets the Element at the given index in this Entry. | |
Element | GetElement (const char *name) |
Gets the Element with the given name from this Entry. | |
size_t | GetElementCount (void) |
Returns the number of elements in this Entry. | |
size_t | GetElementIndex (const char *name) |
Gets the index of the Element with the given name from this Entry. | |
Facility | GetFacility (void) |
Gets the Facility of this Entry. | |
const char * | GetMessage (void) |
Gets the message from this Entry. | |
const char * | GetMsgid (void) |
Gets the msgid of this Entry. | |
Param | GetParam (size_t element_index, size_t param_index) |
Gets the Param from the Element at the given index from this Entry. | |
Param | GetParam (const char *element_name, const char *param_name) |
Gets the first Param from the Element with the given name from this Entry. | |
const char * | GetParamValue (size_t element_index, size_t param_index) |
Gets the value of the Param from the Element at the given index from this Entry. | |
const char * | GetParamValue (const char *element_name, const char *param_name) |
Gets the value of the first Param from the Element with the given name from this Entry. | |
int | GetPrival (void) |
Gets the prival of this Entry, as defined in RFC 5424. | |
Severity | GetSeverity (void) |
Gets the Severity of this Entry. | |
bool | HasElement (const char *name) |
True if this Entry has an Element with the given name, false otherwise. | |
Entry & | SetAppName (const char *app_name) |
Sets the app name for an entry. | |
Entry & | SetElement (size_t index, Element &element) |
Puts the element at the given index in this Entry. | |
Entry & | SetFacility (Facility facility) |
Sets the Facility of this Entry. | |
Entry & | SetMsgid (const char *msgid) |
Sets the msgid for this Entry. | |
Entry & | SetMessage (const char *message,...) |
Sets the message of an Entry. | |
Entry & | SetParam (size_t element_index, size_t param_index, Param ¶m) |
Puts the Param in the Element at the given index of this Entry. | |
Entry & | SetParamValue (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 this Entry. | |
Entry & | SetParamValue (const char *element_name, const char *param_name, const char *value) |
Sets the value of the first Param with the given name in the Element with the given name in this Entry. | |
Entry & | SetPriority (Facility facility, Severity severity) |
Sets the Facility and Severity of this Entry. | |
Entry & | SetPrival (int prival) |
Sets the prival of this Entry, as defined in RFC 5424. | |
Entry & | SetSeverity (Severity severity) |
Sets the Severity of this Entry. | |
Public Attributes | |
struct stumpless_entry * | equivalent |
A log entry.
Entries are the basic element of logging in Stumpless.
stumpless::Entry::Entry | ( | Facility | facility, |
Severity | severity, | ||
const char * | app_name, | ||
const char * | msgid, | ||
const char * | message, | ||
... ) |
Creates an Entry with the given properties.
facility | The facility code of the event this entry describes. |
severity | The severity of the event this entry describes. |
app_name | The app_name of the entry. If this is NULL, then it will be blank in the entry (a single '-' character). |
msgid | The msgid of the entry. If this is NULL, then it will be blank in the entry (a single '-' character). |
message | The message in the entry. This message may contain any format specifiers valid in printf. If this is NULL, then it will be blank in the entry (no characters). This also means that characters such as % need to be escaped as they would be in printf. |
... | Substitutions for any format specifiers provided in message. The number of substitutions provided must exactly match the number of specifiers given. |
stumpless::Entry::Entry | ( | struct stumpless_entry * | entry | ) |
stumpless::Entry::Entry | ( | const Entry & | entry | ) |
stumpless::Entry::~Entry | ( | void | ) |
Destroys the Entry and frees any memory allocated for it.
Entry & stumpless::Entry::AddElement | ( | const char * | name | ) |
Creates a new Element and adds it to this Entry.
Note that duplicate elements are not allowed in RFC 5424, and as such attempts to add an element to an entry already having one with the same name will result in a DuplicateElement exception.
name | The name of the new Element. |
Adds an element to an entry.
element | The element to add. |
Adds an Element to this Entry.
Note that duplicate elements are not allowed in RFC 5424, and as such attempts to add an Element to an Entry already having one with the same name will result in a DuplicateElement exception.
element | A pointer to the element to add. |
Entry & stumpless::Entry::AddParam | ( | const char * | element_name, |
const char * | param_name, | ||
const char * | param_value ) |
Creates a new Param and adds it to the specified Element in this Entry.
If an Element with the given name does not exist in this Entry, then one will be created with the new Param added to it.
Available since release v1.6.0.
element_name | The name of the Element to add the Param to. This will be created if it is not found. |
param_name | The name of the new Param. |
param_value | The value of the new Param. |
const char * stumpless::Entry::GetAppName | ( | void | ) |
Element stumpless::Entry::GetElement | ( | const char * | name | ) |
Element stumpless::Entry::GetElement | ( | size_t | index | ) |
size_t stumpless::Entry::GetElementCount | ( | void | ) |
size_t stumpless::Entry::GetElementIndex | ( | const char * | name | ) |
Facility stumpless::Entry::GetFacility | ( | void | ) |
const char * stumpless::Entry::GetMessage | ( | void | ) |
Gets the message from this Entry.
Note that if this message was originally set using format specifiers, the result will have them substituted instead of the original placeholders. The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. Available since release v2.0.0.
const char * stumpless::Entry::GetMsgid | ( | void | ) |
Param stumpless::Entry::GetParam | ( | const char * | element_name, |
const char * | param_name ) |
Gets the first Param from the Element with the given name from this Entry.
Note that an Element may contain as many instances of a Param as desired according to RFC 5424, and therefore there may be other Param instances with the same name. If you need a reference to other Params with the same name in the Element, then you must loop through all Params using GetParam with an index, checking each name.
Available since release v1.6.0.
element_name | The name of the Element to get the Param from. |
param_name | The name of the Param to get within the Element. |
Param stumpless::Entry::GetParam | ( | size_t | element_index, |
size_t | param_index ) |
const char * stumpless::Entry::GetParamValue | ( | const char * | element_name, |
const char * | param_name ) |
Gets the value of the first Param from the Element with the given name from this Entry.
Note that an Element may contain as many instances of a Param as desired according to RFC 5424, and therefore there may be other Param instances with the same name. If you need the value of other Params with the same name in the Element, then you must loop through all Params using GetParam with an index, checking each name. The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
element_name | The name of the Element to get the Param from. |
param_name | The name of the Param to get the value of within the Element. |
const char * stumpless::Entry::GetParamValue | ( | size_t | element_index, |
size_t | param_index ) |
Gets the value of the Param from the Element at the given index from this Entry.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
element_index | The index of the Element to get the Param from. |
param_index | The index of the Param to get the value of within the Element. |
int stumpless::Entry::GetPrival | ( | void | ) |
Severity stumpless::Entry::GetSeverity | ( | void | ) |
bool stumpless::Entry::HasElement | ( | const char * | name | ) |
Entry & stumpless::Entry::SetAppName | ( | const char * | app_name | ) |
Sets the app name for an entry.
app_name | The new app_name for the entry as a NULL-terminated string. This will be copied in to the entry, and therefore may be modified or freed after this call without affecting the entry. If this is NULL, then a single '-' character will be used, as specified as the NILVALUE in RFC 5424. |
Puts the element at the given index in this Entry.
An Element cannot be set at an index position that does not already hold one. If this is attempted, then an IndexOutOfBounds exception is thrown.
Note that duplicate elements are not allowed in RFC 5424, and as such attempts to set an Element of an Entry which already contains another Element with the same name will result in a DuplicateElement exception.
Available since release v1.6.0.
index | The index to set. |
element | The Element to put at index. |
Entry & stumpless::Entry::SetMessage | ( | const char * | message, |
... ) |
Sets the message of an Entry.
message | The new message to set on the entry. The message may contain any format specifiers valid in printf. If this is NULL, then it will be blank in the entry (no characters). This also means that characters such as % need to be escaped as they would be in printf. |
... | Substitutions for any format specifiers provided in message. The number of substitutions provided must exactly match the number of specifiers given. |
Entry & stumpless::Entry::SetMsgid | ( | const char * | msgid | ) |
Sets the msgid for this Entry.
Available since release v1.6.0.
msgid | A NULL-terminated string holding the new msgid. This will be copied in to the Entry, and therefore may be modified or freed after this call without affecting the entry. If this is NULL, then a single '-' character will be used, as specified as the NILVALUE in RFC 5424. |
Puts the Param in the Element at the given index of this Entry.
A Param cannot be set at an index position that does not already hold one. If this is attempted, then an IndexOutOfBounds exception is thrown.
Available since release v1.6.0.
element_index | The index of the Element to set the Param on. |
param_index | The index of the Param to set. |
param | The new Param. |
Entry & stumpless::Entry::SetParamValue | ( | const char * | element_name, |
const char * | param_name, | ||
const char * | value ) |
Sets the value of the first Param with the given name in the Element with the given name in this Entry.
If an Element with the given name is not found, one is created with the supplied name and added to the end of this Entry.
If a Param of the given name is not found in the named Element, one is created with the supplied name and value and added to the end of the Element.
If you need to set the value of a Param with this name other than the first one, then you will need to loop through the Params using GetParam with an index to find the necessary ones, and then use SetParamValue with the correct index.
Available since release v1.6.0.
element_name | The name of the Element to set the Param value on. |
param_name | The name of the Param to set the value of. |
value | The new value of the Param. |
Entry & stumpless::Entry::SetParamValue | ( | size_t | element_index, |
size_t | param_index, | ||
const char * | value ) |
Entry & stumpless::Entry::SetPrival | ( | int | prival | ) |
struct stumpless_entry* stumpless::Entry::equivalent |