I'm writing a program to log to various places. In it I have some log functions:
(define (write-to-file destination content)
(with-output-to-file destination
(λ ()
(displayln
content))
#:mode 'text #:exists 'append))
(define (write-to-port destination content)
(displayln content destination))
I want to use these functions at run-time. So I have made a list of lists to hold my configuration:
(define log-destinations
'((write-to-file "my.log")
(write-to-port (current-error-port))))
So I have a function that recursively consumes the list log-destinations
:
(define (send-log-content content destinations)
(unless (null? destinations)
(let ([ destination (car destinations)])
(#%app (car destination) (cadr destination) content))
(send-log-content content (cdr destinations))))
However at runtime I'm getting:
application: not a procedure;
expected a procedure that can be applied to arguments
given: 'write-to-file
arguments...:
"my.log"
"[info] web: 2021/03/21 16:26:35 +11:00 /\n"
context...:
Which suggests I've not quoted the function name properly. So how do I quote the function name appropriately in log-destinations
so it can be called correctly at runtime?