Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Reads the logs of orders that completed within the last 8 hours and writes the log output to individual files in the /tmp directory.

  • The log file names are created from the start time, the workflow name and Order ID.

...

Code Block
languagepowershell
titleExample how to write order logs at an ongoing basis
linenumberstrue
# execute once
$lastHistory = Get-JS7OrderHistory -RelativeDateFrom -8h | Sort-Object -Property startTime

# execute in intervals
Get-JS7OrderHistory -DateFrom $lastHistory[0].startTime | Tee-Object -Variable lastHistory | Get-JS7OrderLog | Select-Object @{name='path'; expression={ "/tmp/history/$(Get-Date $_.startTime -f 'yyyyMMdd-hhmmss')-$([io.path]::GetFileNameWithoutExtension($_.workflow))-$($_.orderId).order.log"}}, @{name='value'; expression={ $_.log }} | Set-Content

...

  • Lines 1, 4: Same explanations as for the previous job.
  • Lines 67: The variable holding the list of order log objects of the last processing of this job is restored from a temporary file that holds the JSON representation of the objectobjects. The temporary files is provided by the JS7 Agent and is referenced from an environment variable that is assigned the workflow variable like this.


  • Line 10: When reading the order history then the variable carrying the History ID list of order log objects is updated and is forwarded to the workflow for next execution of the cycle.