Pages

2 juin 2008

Debug a droplet

property debug : true
on open theDrop
aa()
try
repeat with theItem in theDrop
-- script principal
end repeat
on error errorMessage number errorNumber
zz("Error: " & the errorNumber & ". " & the errorMessage)
end try
end open

---============== DEBUG ==============
on aa() -- Creation fichier log
if debug then
set scriptPath to "Path: " & POSIX path of (path to me)
set scriptName to "Script: " & displayed name of (info for (path to me))
set currentDate to "Date/Time: " & (do shell script "date '+%d/%m/%y %H:%M:%S'")
set OSversion to do shell script "sw_vers"
set UserName to "User: " & (do shell script "logname")
set ASVersion to "AppleScript: " & (AppleScript's version as Unicode text)
set addLog to scriptName & return & scriptPath & return & currentDate & return & OSversion & return & ASVersion & return & UserName
do shell script "echo '" & addLog & "' >> ~/Desktop/debug.log"
end if
end aa
on zz(msg) -- Ecriture fichier log
if debug then
set theTime to do shell script "date '+%d/%m/%y %H:%M:%S'" -- Ex: 19/01/59  16:30:00"
do shell script "echo '" & theTime & " " & msg & "' >> ~/Desktop/debug.log"
end if
end zz
---============== /DEBUG ==============

>>Ouvrir le script dans l'éditeur

Aucun commentaire: