So I created the following and am looking for feedback/suggestions. The logging routines are fairly straight foreward, so I haven't included them here:
Procedures that have been redefined are:
Alert
Princ
Implementation:
Just prior to running your script add this file to your appload startup suite, and load it.
Run your script:
All messages that would have gone to alert boxes will instead be sent to the command line
and to the error log (via WriteToErrorLog loaded from Logging.lsp). All messages that
would be sent to the command line via princ will also be sent to the the action log via
WriteToActionLog, again from logging.lsp. Included with the information sent to the logs
is the names of all active commands at the time the entry is logged.
After running your script:
To restore normal behavior of Alert and Princ, run "RestoreAlerts" at the command prompt.
Perhaps do this as the last line in your script.
(if (and OldAlert (= 'USUBR (type alert)))
nil
(setq
OldAlert alert
OldPrinc princ
)
)
(pragma '((unprotect-assign alert)))
(pragma '((unprotect-assign princ)))
(defun alert (msg)
(if writetoerrorlog
nil
(load "logging")
)
(writetoerrorlog msg (getvar "cmdnames"))
(oldprinc msg)
(oldprinc)
)
(defun Princ (msg)
(writetoactionlog (strcat (getvar "cmdnames") "|" msg))
(oldprinc msg)
(oldprinc)
)
(pragma '((protect-assign alert)))
(pragma '((protect-assign princ)))
(defun c:RestoreAlerts ()
(pragma '((unprotect-assign alert)))
(pragma '((unprotect-assign princ)))
(setq
alert OldAlert
princ OldPrinc
)
(pragma '((protect-assign alert)))
(pragma '((protect-assign princ)))
(princ)
)
(progn
(princ
"\nLoading AlertToLog will send all alert messages to the error log."
)
(princ
"\nRun \"RestoreAlerts\" to restore normal alert behavior."
)
(princ)
)