I'm not sure I understand your question, but the second argument to format is the stream . If you set it to t , it prints to standard output, but you can also set it to an open file.
So, something like this will let you choose where the output goes:
;;output to file: (setf *stream* (open "myfile" :direction :output :if-exists :supersede) ;;alternative to output to standard output: ;;(setf *stream* t) (defun foo (x) (format *stream* "x = ~s~%" x)) (foo 10) (close *stream*) ;; only if output sent to a file
source share