Logging Problems

I'm having trouble with finding in the documentation creating custom log files.

I wish to create a log file that different scripts will write to to log results and other information, but nothing that is automatically generated by the program. so if i have 20 scripts and i want to output "Test script abcd was able to finish but with some errors" then list the errors or just "Test script dcba was a Success." or whatever message i wanted to output to it.

I don't want any of the automatically generated messages in this log file only my own. Also, once i have refined this, i will no longer require eggplant to make the default log files for each script.

So the the list of requirements for the log script would be:
*No automatically Generated log information
*New custom date-stamped log in chosen directory


I have a general idea how to do this but im not all the way there. I can create a string for the log name and information i want to put in i just don't know how to create the log and then log to it.

Comments

  • I have thought of a work-around for this problem by creating a log file on a different connection and having eggplant scrip it in, but it would be much better if i could log this information the correct way.

    Please i need to know how to create a log in a custom directory and write to it.
  • Almost have it..

    Here is my script:
    set testlist to ("1-4_Verify_UI", "Cleanup")
    set logfolder to "/home/eggplant/Documents/IETM_Regression.suite/Results/" & "IETM_Regression_Test_" & the basic date & the abbrev time & ".log"
    Create file logfolder
    RunWithNewResults "QA_Open_IETM"
    put the result into outcome
    
    If the status of outcome is not "Success" then
    	put "CDI Open IETM sript Failed!"
    else
    	repeat with each testScript of testlist
    		RunWithNewResults testscript
    		put the result into outcome
    		put testScript & ":" && status of outcome && Return after currentReport
    		if the status of outcome is "Failure" then
    			run "cleanup"
    		end if
    	end repeat
    	log "Final Results"
    	repeat with each line of currentReport
    		log it
    		Put testScript & ":" && status of outcome into file logfolder
    	end repeat
    end if
    

    Whats happening is the "Put testScript & ":" && status of outcome into file logfolder" is overriding itself, so insead of going to the next line with the results its just replacing it. also i might have it in the wrong place.

    For each script i run i want it to log a new line, i will make this more robust adding specific test information once i get the basics working.
    Any ideas?
  • Still need to figure out how to append a file.

    any clues?
    set testlist to ("1-4_Verify_UI", "Cleanup")   
    (*& the basic date & "_" & the abbrev time & *)
    
    set logfolder to "/home/eggplant/Documents/IETM_Regression.suite/Results/" & "IETM_Regression_Test_" & ".log"
    
    Create file logfolder with appendOnly
    RunWithNewResults "QA_Open_IETM"
    put the result into outcome
    
    set logtext to "1-4_4.1.10_QA_UI Test Results; " & cr & testScript & ":" && status of outcome & cr
    
    If the status of outcome is not "Success" then
    	put "QA Open IETM sript Failed!"
    else
    	repeat with each testScript of testlist
    		RunWithNewResults testscript
    		put the result into outcome
    		put testScript & ":" && status of outcome && Return after currentReport
    		set logtext to logtext & testScript & ":" && status of outcome & cr	
    		if the status of outcome is "Failure" then
    			run "cleanup"
    		end if
    	end repeat
    	log "Final Results"
    	repeat with each line of currentReport
    		log it
    		put logtext into file logfolder
    	end repeat
    end if
    

    here is where i am at, i used cr to move down lines but still cannot get scripts to append to a single file, it just over-writes it.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Right. When you do this:
    put logtext into file logfolder
    
    you are replacing the contents of the file each time. The simplest way to append to the file is to just do this instead:
    put logtext & return after file logfolder
    
    There are other ways to do it using the open file and write to file commands, but unless you're doing a whole lot of logging I don't think there would be any benefit to that approach. Simple is usually better. :-)

    To turn off Eggplant's usual logging, use this command:
    set the ScriptLogging to Silent
    
    You could also set it to Off or Minimal, depending on your needs (see the documentation for a description of the different modes).
  • Worked great! thanks!
Sign In or Register to comment.