WriteLog Function

The WriteLog function writes a single event to your modular output system outputs.

The following parameters are supported…

ParameterDefaultMeaning
nameThe primary name/text/description of your event
duration0The length of the event, in seconds
offset0The difference (in seconds) between the event and the current time
optionsNoneOptions to pass to the function (see Options)
configNoneContains additional outputs/destinations

Parameters

Name

The name is the main description of the event. Note that you can pass additional details in 'options' and format them differently depending on the various output methods you're using.

#Creates an instant log entry at the current time
oe.WriteLog("System Stopped")
Duration

The length of the event, in seconds.

#Creates a 3-minute long event that finishes at the current time.
oe.WriteLog("System Stopped",3*60)
Offset

The amount of time that has passed (in seconds) between the end of the event and this write operation.

Mainly used when recording events that have happened in the past, rather than those that are happening live.

This shifts both the start and end times of the event by the given number of seconds.

#Creates a 30 minute log entry, ending an hour ago.
oe.WriteLog("System Stopped",30*60,60*60)
Options

Options are passed as a dictionary of option names and values.

Option NameMeaning
datatypeForces a certain data type - for example, 'text'

Other options can be used as conditions for different output methods, and can also be used when substituting values.

For example,

oe.WriteValue("Machine Stopped",options={"machineid": "45","location": "South"})

…would be the command in Python, and with the following output…

[{
    "type": "event",
    "method": "teams_webhook",
    "url": "<my webhook url>",
    "content": "A %M alert has been raised on unit %MACHINEID %LOCATION"
}]

…a Teams message would appear in the chosen Team saying 'A Machine Stopped alert has been raised on 45 South“

Config

In some cases, your application might have a specific destination in mind for the results. This allows you to send a dictionary containing output configuration details.

This lets you provide a UI to the user setting up specific, per-event delivery rules.

oe.WriteLog("Stopped Running",config=[{"method": "logfile", "path": "c:\testing\issues.log"}])