www-utils::notify-log-window
A thread safe macro like with-output-to-editor-stream should be
provided by Lispworks so users do not need to wedge specialized code
into their applications
It looks to me like one the point is locked, we have captured a lock
on the editor buffer, so this macro should be fairly easy to write.
The way this is written we are going to cons strings for each entry.
It would be better to pass a closure that just prints out the line.
#+(and LispWorks (not (or lispworks4 lispworks5.0)))
(define notify-log-window (format-string &rest format-args)
"Top-level method for writing to the HTTP log window.
FORMAT-STRING can also be a function applied to STREAM,
in which case FORMAT-ARGS are ignored."
(declare (dynamic-extent format-args))
(let ((string (with-output-to-string (stream)
(fresh-line stream)
(write-char #\[ stream)
(http::write-standard-time (get-universal-time)
stream)
(write-string "] " stream)
(etypecase format-string
(string
(apply #'format stream format-string format-args))
(function (funcall format-string stream)))))
(point (editor:editor-stream-point *log-window-output-
stream*)))
(editor:with-point-locked (point)
(let ((buffer (editor:point-buffer point)))
(editor:insert-string (editor:buffers-end buffer) string)
(when (and *log-window-output-line-count*
(>= (incf *log-window-output-line-count*)
*log-window-output-line-limit*))
(let ((keep-lines (floor *log-window-output-line-limit* -2)))
(editor:with-point ((point (editor:buffers-end buffer)))
(editor:line-offset point keep-lines)
(editor:delete-between-points (editor:buffers-start
buffer) point)
(editor:insert-string
point (load-time-value (format nil "---older lines
deleted---~%")))
(editor:use-buffer buffer (editor:clear-undo-command
buffer))))
(setq *log-window-output-line-count* 0))
(finish-output *log-window-output-stream*)))))