DatabaseEventWriter¶
Description¶
The DatabaseEventWriter object is an EventOutput which stores Event objects in a database whenever triggered. All inserted Events can later be queried using a DatabaseQuery object and assigning the eventTable property to DatabaseQuery.table.
› Inherits: | EventOutput |
---|
Properties¶
database¶
This property holds the Database in which the Event objects are stored. If left blank a LocalDatabase is created.
› Type: | Database |
---|---|
› Signal: | databaseChanged() |
› Attributes: | Writable, Optional |
error¶
This property holds the most recently occurred error or DatabaseEventWriter.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
› Type: | Error |
---|---|
› Signal: | errorChanged() |
› Attributes: | Readonly |
errorString¶
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
› Type: | String |
---|---|
› Signal: | errorStringChanged() |
› Attributes: | Readonly |
eventTable¶
This property holds the DatabaseEventTable object which handles the mapping from Event properties to database table columns. During initialization it is attached to the database held by the database property.
› Type: | DatabaseEventTable |
---|---|
› Signal: | eventTableChanged() |
› Attributes: | Readonly |
Signals¶
Enumerations¶
Error¶
This enumeration describes all errors which can occur in DatabaseEventWriter objects. The most recently occurred error is stored in the error property.
Name | Value | Description |
---|---|---|
DatabaseEventWriter.NoError |
0 |
No error occurred or was detected. |
DatabaseEventWriter.InvalidDatabase |
1 |
Invalid or no database set. |
DatabaseEventWriter.InvalidIdError |
2 |
Empty or invalid object ID (only alphanumeric characters allowed). |
Example¶
import InCore.Foundation 2.5
import InCore.Database 2.5
Application {
EventLog {
outputs: [
DatabaseEventWriter {
id: eventWriter
//property database left blank to create a LocalDatabase
} ]
EventCategory { id: measurementValueCategory }
EventGroup {
Event {
id: temperatureEvent
description: "temperature above 70°C"
}
Event {
id: deviceStartedEvent
description: "device started"
}
Event {
id: measurementValueEvent
description: "measurement above threshold"
category: measurementValueCategory
severity: Event.Error
}
}
}
onCompleted: deviceStartedEvent.trigger()
//trigger events here
}