|
StartLogging |
|
|
Creates new log file(s) and starts logging the incoming/outgoing serial data.
Return Value
Void
Syntax
DL.StartLogging baseFilePath [, appendData] [, representations] [, html] [, highspeed] [, noHeaders]
The StartLogging method syntax has these parts:
Remarks
See also logging and analyzing a test and the Create Log Files(s) Dialog for more information on the StartLogging functionality and arguments described above.
If baseFilePath is an empty string, a file dialog will be displayed to choose the log file path and base file name.
If StartLogging is called while another log file is still open from a previous StartLogging call, the file is closed and the new file is created / opened. This allows changing the log file name without losing any data.
The noHeaders flag is particularly useful when you are creating log data without time stamps. You can then easily compare the result to previous test runs using an file compare tool.
Example
' Example StartLogging
DL.ClearCommWindows DL.StartLogging "C:\DocklightLogging" ' - opens four log files: ' 'C:\DocklightLogging_asc.txt' ' 'C:\DocklightLogging_hex.txt' ' 'C:\DocklightLogging_dec.txt' ' 'C:\DocklightLogging_bin.txt' ' Wait for 5 seconds DL.Pause 5000 ' Close the four log files DL.StopLogging
This is a more advanced example which demonstrates how to include a date/time stamp in the log file name and start a new log file every hour
' Example 'One Log File per Hour'
' This is the base path and location where the log file(s) will be stored Const BASE_FILE_PATH = "logfile_" ' Create ASCII and HEX log files Const LOG_REPRESENTATIONS = "AH"
currentLogFileName = "" DL.StartCommunication Do newLogFileName = getFileName() ' Time for starting a new file? If newLogFileName <> currentLogFileName Then DL.StartLogging newLogFileName, True, LOG_REPRESENTATIONS currentLogFileName = newLogFileName End If DL.Pause 1 ' reduce CPU load Loop
Function getFileName() dt = Now ' Compose a file name. ' The Right() functions ensure that all months, days, ' hours are printed with two decimals getFileName = BASE_FILE_PATH & Year(dt) & "_" & Right("0" & Month(dt), 2) & "_" & Right("0" & Day(dt), 2) & "_" & Right("0" & Hour(dt), 2) & "H" End Function |