I'm not sure that's the best solution.  Running into trouble
while trying to log an error message is always a pain in
the neck, but it's usually not best to just go ahead anyway.
I try to write fallbacks.  (Hans, I'm sure you know about
this idea; I'm just saying it might be good in this case.)

Here's a simple example of what I mean.

(defun safe-format (stream control-string &rest format-arguments)
  "This is like FORMAT, except that if a condition is signaled
   during the call to FORMAT, it falls back by printing the
   FORMAT control string, followed by as many of the arguments
   as possible.  This function never signals any conditions.
   This means that it can hide errors, so it should not be used
   widely.  It is intended to be used in code that reports
   errors and stack traces, and in logging."
  (handler-case
      (apply #'format stream control-string format-arguments)
    (serious-condition ()
      (ignore-errors
        (flet ((print-fallback (stream)
                 (princ "Error during format: " stream)
                 (princ control-string stream)
                 (dolist (arg format-arguments)
                   (princ " " stream)
                   (handler-case
                       (princ arg stream)
                     (serious-condition ()
                       (ignore-errors
                         (princ "[error printing argument of type " stream)
                         (ignore-errors
                           (princ (type-of arg) stream))
                         (princ "]" stream)))))))
          (if (null stream)
            (with-output-to-string (strm)
              (print-fallback strm))
            (print-fallback stream)))))))

-- Dan


Hans Hübner wrote:
On Wed, Jun 16, 2010 at 01:49, Cyrus Harmon <ch-tbnl@bobobeach.com> wrote:
  
So, while trying to track down an unrelated issue where my handlers aren't getting called anymore, I came across the following issue where failure to open the message log file results in an error, which, in turn, attempts to open the message log file. The problem in this case was that the permissions were bogus for the directory I was trying to open. But, still, we should probably have a nicer error message than "recursive lock attempt" here.
    

I agree.  Can you supply a patch that corrects the problem?  Using a
recursive lock would probably the easiest solution.

Thanks,
Hans

_______________________________________________
tbnl-devel site list
tbnl-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/tbnl-devel