EventLog

Description

The EventLog object is used to couple EventOutputs with EventLogItems for example a EventGroup. Each event is delivered to all outputs. Internally this object is used to redirect Event.trigger() calls to the outputs.

› Inherits:Object

Properties

items

This property holds a list of EventLogItem objects. Each event will be delivered to all outputs.

› Type:List<EventLogItem>
› Signal:itemsChanged()
› Attributes:Readonly

outputs

This property holds a list of outputs.

› Type:List<EventOutput>
› Signal:outputsChanged()
› Attributes:Readonly

Signals

itemsDataChanged(SignedInteger index)

This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the items list itself emitted the dataChanged() signal.

outputsDataChanged(SignedInteger index)

This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the outputs list itself emitted the dataChanged() signal.

Example

import InCore.Foundation 2.5
import InCore.Database 2.5

Application {

    Timer {
        interval: 5000
        onTriggered: timerEvent.trigger()
    }

    EventLog {
        // define categories to group events - its id can be handled in the outputs
        EventCategory {
            id: customCategory
        }
        EventCategory {
            id: deviceCategory
        }

        // each Event in the group will inherit the groups category and severity except for it overrides them
        EventGroup {
            category: customCategory
            severity: Event.Warning
            Event {
                id: omniscientEvent
                errorCode: 42
                name: "omniscient event"
                description: "the answer to life, the universe and everything"
            }
            Event {
                id: timerEvent
                name: "Timer event"
                description: "the timer timed out"
            }
        }

        EventGroup {
            severity: Event.Information
            Event {
                id: deviceStartedEvent
                name: "device started"
                description: "the device was started"
                category: deviceCategory
            }
        }

        // each event will be delivered to all outputs, but only handled if the filtering based on category or severity matches
        outputs: [ journal, writer ]
    }

    // this outputs date, time, name and description of the event to the journal if the category matches
    EventJournal {
        id: journal
        filterCategories: [ deviceCategory ]
    }

    // write everything with minimum severity level 'information' to the database
    DatabaseEventWriter {
        id: writer
        filterMinimumSeverity: Error.Information
    }

    onCompleted: deviceStartedEvent.trigger()
}