.. _object_EventLogFile: :index:`EventLogFile` --------------------- Description *********** The EventLogFile object is a :ref:`EventOutput ` and writes events to a :ref:`IoDevice ` for example a :ref:`File `. Each event is printed in a new line prefixed with the current date and time and the event's severity. The :ref:`log() ` method can be used to print messages to the IoDevice directly. :**› Inherits**: :ref:`EventOutput ` Overview ******** Properties ++++++++++ .. hlist:: :columns: 2 * :ref:`dateTime ` * :ref:`error ` * :ref:`errorString ` * :ref:`output ` * :ref:`outputMode ` * :ref:`EventOutput.filterCategories ` * :ref:`EventOutput.filterExactSeverity ` * :ref:`EventOutput.filterMinimumSeverity ` * :ref:`Object.objectId ` * :ref:`Object.parent ` Methods +++++++ .. hlist:: :columns: 1 * :ref:`log() ` * :ref:`Object.deserializeProperties() ` * :ref:`Object.fromJson() ` * :ref:`Object.serializeProperties() ` * :ref:`Object.toJson() ` Signals +++++++ .. hlist:: :columns: 1 * :ref:`errorOccurred() ` * :ref:`EventOutput.filterCategoriesDataChanged() ` * :ref:`Object.completed() ` Enumerations ++++++++++++ .. hlist:: :columns: 1 * :ref:`Error ` * :ref:`OutputMode ` Properties ********** .. _property_EventLogFile_dateTime: .. _signal_EventLogFile_dateTimeChanged: .. index:: single: dateTime dateTime ++++++++ This property holds a :ref:`DateTime ` object whose :ref:`DateTime.highPrecisionString ` property is used to format the date for log messages. It can be used to customize the date formatting. :**› Type**: :ref:`DateTime ` :**› Signal**: dateTimeChanged() :**› Attributes**: Writable .. _property_EventLogFile_error: .. _signal_EventLogFile_errorChanged: .. index:: single: error error +++++ This property holds the most recently occurred error or :ref:`EventLogFile.NoError ` if no error occurred. If the same error occurs multiple times this property does not change. Use the :ref:`errorOccurred() ` signal to detect multiple occurrences of the same error. :**› Type**: :ref:`Error ` :**› Signal**: errorChanged() :**› Attributes**: Readonly .. _property_EventLogFile_errorString: .. _signal_EventLogFile_errorStringChanged: .. index:: single: errorString errorString +++++++++++ This property holds the current human readable error string corresponding to the current value in the :ref:`error ` property. It may include additional information such as failure reasons or locations. :**› Type**: String :**› Signal**: errorStringChanged() :**› Attributes**: Readonly .. _property_EventLogFile_output: .. _signal_EventLogFile_outputChanged: .. index:: single: output output ++++++ This property holds the output device (e.g. :ref:`File `) to which the log messages are written. :**› Type**: :ref:`IoDevice ` :**› Signal**: outputChanged() :**› Attributes**: Writable .. _property_EventLogFile_outputMode: .. _signal_EventLogFile_outputModeChanged: .. index:: single: outputMode outputMode ++++++++++ This property holds the output mode which specifies how to open the output at start, i.e. append messages or start from scratch everytime. :**› Type**: :ref:`OutputMode ` :**› Default**: :ref:`EventLogFile.OutputAppend ` :**› Signal**: outputModeChanged() :**› Attributes**: Writable Methods ******* .. _method_EventLogFile_log: .. index:: single: log log(args) +++++++++ This method prints a new line to the IoDevice. Each line consists of a date time and the given arguments separated by space. Signals ******* .. _signal_EventLogFile_errorOccurred: .. index:: single: errorOccurred errorOccurred() +++++++++++++++ This signal is emitted whenever an error has occurred, regardless of whether the :ref:`error ` property has changed or not. In contrast to the change notification signal of the :ref:`error ` property this signal is also emitted several times if a certain error occurs several times in succession. Enumerations ************ .. _enum_EventLogFile_Error: .. index:: single: Error Error +++++ This enumeration describes all errors which can occur in EventLogFile objects. The most recently occurred error is stored in the :ref:`error ` property. .. index:: single: EventLogFile.NoError .. index:: single: EventLogFile.OutputNotSetError .. index:: single: EventLogFile.OutputOpenError .. list-table:: :widths: auto :header-rows: 1 * - Name - Value - Description .. _enumitem_EventLogFile_NoError: * - ``EventLogFile.NoError`` - ``0`` - No error occurred or was detected. .. _enumitem_EventLogFile_OutputNotSetError: * - ``EventLogFile.OutputNotSetError`` - ``1`` - Output not set. .. _enumitem_EventLogFile_OutputOpenError: * - ``EventLogFile.OutputOpenError`` - ``2`` - Could not open output. .. _enum_EventLogFile_OutputMode: .. index:: single: OutputMode OutputMode ++++++++++ This enumeration describes the output mode of the :ref:`EventLogFile `. .. index:: single: EventLogFile.OutputAppend .. index:: single: EventLogFile.OutputTruncate .. list-table:: :widths: auto :header-rows: 1 * - Name - Value - Description .. _enumitem_EventLogFile_OutputAppend: * - ``EventLogFile.OutputAppend`` - ``0`` - Append lines at the end of :ref:`output `. The file is never deleted or truncated with this mode. .. _enumitem_EventLogFile_OutputTruncate: * - ``EventLogFile.OutputTruncate`` - ``1`` - Truncate the file each time it is opened, i.e. every application start or whenever opened and closed manually. .. _example_EventLogFile: Example ******* .. code-block:: qml import InCore.Foundation 2.5 Application { EventLogFile { id: logFile // log to file stored on persistent local storage output: File { storage: LocalStorage { } fileName: "myapp.log" } } onCompleted: logFile.log("App started with random value", Math.random()) }