PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

Log to file package guide

Use Log to File to write text or typed values to a Device file or to the room Run log.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Prerequisites

Shared fields

FieldEditor fieldType; default; required/optionalApplies toUse
variablesVariables to logDictionarydefault {}optionallogToFileServer⁠, logToFileVariablesA Dictionary of names and values, e.g. $summary$ with Number count=3 and String status=ready⁠. Values are written as name=value⁠, in the order they were added. Credential passwords are hidden.
filePathFile path (Log text), Output file path (Log variables)Stringdefault ""requiredlogToFileText⁠, logToFileVariablesLog file, e.g. samples/run.log⁠. What happens to old text depends on logOption⁠.
appendTimestampAppend timestampBooleandefault falseoptionallogToFileText⁠, logToFileVariablestrue puts the same local time before each line of the entry, as yyyy-MMM-dd HH:mm:ss ±HHmm⁠. false writes only the text.
logOptionWhen loggingLogOptiondefault APPEND_FILEoptionallogToFileText⁠, logToFileVariablesAPPEND_FILE keeps the old text and adds the entry. OVERWRITE_FILE replaces the whole file with this entry.

Actions

Log to Server (logToFileServer)

Write a message, and optional values, to the Run log in the room.

Inputs

InputEditor fieldType; default; required/optionalUse
textToLogText to logStringdefault ""requiredMessage, e.g. Invoice batch complete⁠. It is written as you type it, so do not put secrets in it.
tagsData source tagStringdefault ""optionalorders adds [orders] before the message. The whole text is one tag.
logLevelLog levelServerLogLeveldefault InfooptionalWord put before the message, in capitals: Emergency⁠, Error⁠, Warn⁠, Info or Debug⁠.

Also uses the shared fields: variables.

Outputs

None.

Example

Prepare Dictionary summary with Number count=3. Set textToLog=step done, tags=orders, logLevel=Warn, variables=$summary$.

Expected result

The Run log gets WARN [orders] step done, then a separate line count=3. An empty Dictionary adds no value lines. If the log cannot be written, the step fails.

Back to actions

Log text to file (logToFileText)

Add or replace a text entry in a Device file. Each line can have a time, and the entry ends with a new line.

Inputs

InputEditor fieldType; default; required/optionalUse
logContentEnter text to logStringdefault ""requiredText to write. Each line stays one line, and the entry ends with a new line. The text is not hidden.
encodingValueEncodingLogEncodingdefault UTF8optionalUTF8 is right for most logs. UNICODE and UTF16LE write UTF-16 (little-endian). ANSI writes Windows-1252, whatever the Device language. When you add to a log, keep its encoding.

Also uses the shared fields: filePath, appendTimestamp, logOption.

Outputs

None.

Example

With no samples/run.log yet, set filePath=samples/run.log, logContent=one, appendTimestamp=false, logOption=APPEND_FILE, encodingValue=UTF8. Repeat with logContent=two.

Expected result

The file has the lines one and two, each with a new line. With OVERWRITE_FILE, a third entry three leaves only three and its new line. The step fails if the path is not valid, or the file is locked or cannot be written.

Back to actions

Log variables to file (logToFileVariables)

Write the values of a Dictionary as UTF-8 name=value lines. Credential passwords are hidden.

Inputs

Uses the shared fields: filePath, logOption, appendTimestamp, variables.

Outputs

None.

Example

Prepare Dictionary summary with Number count=7 and String status=ready. Set filePath=samples/variables.log, logOption=OVERWRITE_FILE, appendTimestamp=false, variables=$summary$.

Expected result

The file has count=7 and status=ready on separate lines, in Dictionary order. A Credential shows as username:********. Other text does not change. An empty Dictionary still writes one empty line.

Back to actions