DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Speichern Logdatei / DEM_ERRS

Hallo,

 

eine SUD- Anwendung wird automatisiert über den Aufgabenplanung von Windows abhandelt. Um den Ablauf meiner SUD- Anwendung zu überwachen und Zeiten einzelner Teilprozesse herauszufinden, würde ich gerne die Logdatei über das Script steuern. Leider konnte ich bei den "Logdatei-Parameter" noch nichts passendes finden zum speichern dieser.

Gibt es die Möglichkeit diese Logdatei über einen Script-Befehl zu speichern bzw. einen Einfluss auf die "DEM_ERRS"- File zu haben? Ebenfalls interessant wäre diese Logdatei in einem bestimmten Ordner mit bestimmten Namen zu speichern.

 

Vielen Dank im Voraus,

Thomas

0 Kudos
Message 1 of 7
(5,647 Views)

Hi Thomas,

 

All I'm aware of is the ability to execute the LogFileDel() command before the interesting activities and then copy the log file after the interesting activities.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 7
(5,638 Views)

Hi,

 

you can also use the TextFileOpen-Command with the "eTextFileAttributeLogDIAdemMsg" parameter (DIAdem 2014, in 2012 the parameter has a different name but exists). With this parameter, all your log output will be written to the textfile.

 

Greetings,

Martin

0 Kudos
Message 3 of 7
(5,608 Views)

Hello Martin,

 

thank you for the clue.

In this way I create a text-File and write interestings acitvities into. Rather the procedure in respect to the Diadem messages could be easier?

I'm also trying to use the existing Diadem logFile, but it does not work.

 

Dim LogFile

LogFile = TextFileOpen("C:\Users\z003et6f\Desktop\Neuer Ordner\logFile.txt", TfCreate)

Call TextfileWriteLn(LogFile, TfLogDIAdemMsg)

Call TextfileClose(LogFile)

 

Probably it is quite easy. Do you what the problem is?

 

Thank you again,

Thomas

0 Kudos
Message 4 of 7
(5,465 Views)

Hi Thomas,

 

the correct statements are:

 

Dim iTxtHandle
iTxtHandle = TextFileOpen(DataReadPath & "logfile.txt", tfCreate OR tfWrite OR tfLogDIAdemMsg)
Call LogfileWrite("This text will appear in your console and in the text file")
Call LogfileWrite("This text too.")
Call TextFileClose(iTxtHandle)

 You can also capsulate your code with "On Error"-statements and write the errors in the file:

On Error Resume Next
Dim iTxtHandle
iTxtHandle = TextFileOpen(DataReadPath & "logfile.txt", tfCreate OR tfWrite OR tfLogDIAdemMsg)
Call LogfileWrite("Start my script")
Call myScript()

'Error Handling - if no error occured the next statements produces no output
Call LogfileWrite(Err.number)
Call LogfileWrite(Err.Source)
Call LogfileWrite(Err.Description)
Call TextFileClose(iTxtHandle)

On Error Goto 0

 

Greetings,

Martin

0 Kudos
Message 5 of 7
(5,451 Views)

Hello Martin,

 

thank you.

With your Script in the console of Diadem all of the log-File and the written messages is showed. But text-File which is stored include only the written messages with LogfileWrite but not the whole log-File like in the console.

So what I want to do is to create a log-File in a own path with all of the log-File of Diadem and the messages I have written. In other words I want to save the log-File which is shown in the console.

Is that possbile? 

 

Many thanks,

Thomas

0 Kudos
Message 6 of 7
(5,435 Views)

Hi,

 

you can try this (see code below). You can define a class which first will get the normal logfile (depending on your version, the path may differ). With an external constructor you define your target logfile. The clue is, even if your code crashes, DIAdem or VB tries to execute every "Class_Terminate" method. So it's lika a finally call in java, which i find very usefull to store some stuff for example.

Here we go:

 

Class MyLogfile
  Private sLogfile
  Private sTargetfile
  
  Public Sub setTargetFile(sNewFile)
    sTargetfile = sNewFile
  End Sub
  
'Try to get DIAdem log file (on start it's always dem_errs.001) Private Sub Class_Initialize Dim oShell, oEnv Set oShell = CreateObject("wscript.shell") Set oEnv = oShell.Environment("process") 'or maybe on XP ProgramDrv sLogfile = oEnv("localappdata") & "\" sLogfile = sLogfile & "National Instruments\DIAdem\2014 (32-bit)\DEM_ERRS.001"
'If logfile is found, clean it If (FilEx(sLogfile)) Then Call LogfileDel() Else sLogfile = "" End If End Sub
'On termination, copy it to wherever you want Private Sub Class_Terminate If (sLogfile <> "") Then Call FileCopy(sLogfile, sTargetfile) End If End Sub End Class Function MyLogfileExternalConstructor(sNewFile) Set MyLogfileExternalConstructor = new MyLogfile MyLogfileExternalConstructor.setTargetFile(sNewFile) End Function 'Instantiate the class before your real script begins Dim a : Set a = MyLogfileExternalConstructor("D:\PUBLIC\log_" & RTT(Now,"#yyyymmdd_hhnnss") & ".txt") 'Clean termination, Class_Terminate will also be called if code crashes elsewhere or your code ends successfully Set a = nothing

 

 

Greetings,

Martin

0 Kudos
Message 7 of 7
(5,408 Views)