;; ;; util-stdout.scm ;; ;; Output with possibility of complete silencing. ;; ;; ISC License ;; ;; Copyright 2023 Brmlab, z.s. ;; Dominik Pantůček ;; ;; Permission to use, copy, modify, and/or distribute this software ;; for any purpose with or without fee is hereby granted, provided ;; that the above copyright notice and this permission notice appear ;; in all copies. ;; ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE ;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR ;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS ;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, ;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;; (declare (unit util-stdout)) (import duck) (module* util-stdout #:doc ("Very simple module wrapping standard output.") ( *stdout-quiet* stdout-print stdout-printf stdout-newline ) (import scheme (chicken base) (chicken format)) (define/doc *stdout-quiet* ("A boolean parameter which disables all output from procedures in this module if its value is ```#t```.") quiet (make-parameter #f)) (define/doc (stdout-print . args) ("If not quiet, passes ```args``` to ```print```.") (when (not (*stdout-quiet*)) (apply print args))) (define/doc (stdout-printf fmt . args) ("If not quiet, prints formatted string ```fmt``` by applying ```args``` to ```format``` procedure.") (when (not (*stdout-quiet*)) (print (apply format fmt args)))) (define/doc (stdout-newline) ("If not quiet, calls ```(newline)```.") (when (not (*stdout-quiet*)) (newline))) )