@greg Thanks for the example, but I’m still very confused…
First of all, what does the default logger, the (current-logger)
logger, do? Where does it output the logs?
Second, What does a log receiver do? What problem does it solve? When should I use it?
@markx If you are using DrRacket, you can find the logger in the “View” menu.
@markx You can simply use printf
. Seriously. I often do. It’s a time-honored tradition. There are two problems (you might or might not have) which loggers solve: 1- At runtime you want toggle which sets of messages are displayed. So, which logger “facility”, i.e. a define-logger
name. 2- At runtime you want to set what level of messages are displayed (debug … fatal). And, if the string to display requires some expensive work to prepare, you’d like that work not to happen at all if the message won’t be displayed due to 1 or 2.
@soegaard2 Hmm, no I don’t use DrRacket. I just want to log to a file.
@greg But what problems do logger receivers
solve?
@greg And yeah I do want to use a logger, over printf
. But I want to output logs to a file, or later maybe to cloudwatch or anything.
In the docs there’s this example: > (let ([my-log (open-output-string)])
(with-logging-to-port my-log
(lambda ()
(log-warning "Warning World!")
(+ 2 2))
'warning)
(get-output-string my-log))
"Warning World!\n"
There can be zero or more log receivers. Each can do something different. One displays. One writes to file. One writes to CloudWatch. Plus, each receiver can have its own level to show (just fatal, or, everything even debug).
But I don’t want to call this big chunk everytime I want to log, and I don’t want to open and close the file everytime I log something, I guess.
Ideally, I was looking for something like, I globally setup the logger to output to a file, and then later when I call log-info
or whatever, that log will just go to the log file.
That’s described in the docs somewhere.
OK the syslog is described, but not your own file.
BTW is there a easy way to edit the docs? I often feel confused after reading the docs without examples. Unless it’s just me, or we should maybe put the stuff into the docs.
has to go AFK for an hour or two
OK I found this. A good example about log receivers. https://gist.github.com/Metaxal/6511048
Is there a reliable way to rebuild outdated bytecode files? I have tried raco setup --fast-clean && raco setup
, which took forever but didn’t solve the problem.
-j <n>, —jobs <n>, —workers <n> : Use <n> parallel jobs
Can’t remember if raco setup uses 1 or more cores as default.
Try -j 4 and see if it helps.
I think it uses all cores (I see e.g. “raco setup: 7 making:”), but the speed isn’t the problem.
Is it the drracket zo-files, that aren’t updated?
It is all at the command line. After running the above I am still getting: Sapientia:config philip$ ./no-voyant-test.rkt
instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: idY89.1
exporting instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/14/char-set.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/13/string.rkt"
Over my pay grade :slightly_smiling_face:
Bot it says “possibly”, so maybe the problem is elsewhere?
It could be, but I’ve chased the error to srfi-lite-lib
from net/cookies
and web-server
by deleting compiled/
directories.
Does a test program that does nothing but requiring srfi/13 work?
Yes, I can run #lang racket
(require srfi/13 srfi/14)
That’s odd.
Maybe it is a specific function / macro / variable from srfi–14 that causes the problem.
The “name: idY89.1” might mean that it is produced by a macro.
Work around: use srfi/14 instead of srfi-lite/14
?
The thing is, my code doesn’t import any of those modules.
Oh.
By running raco setup srfi net/cookies web-server ricoeur
, I now get: instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: s:string->list
exporting instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/13/string.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/net-cookies-lib/net/cookies/common.rkt"
(where ricoeur
is my collection)
srfi/13/string.rkt is mentioned again
Yes, but then running raco setup --fast-clean srfi net/cookies web-server && raco setup srfi net/cookies web-server ricoeur
has now changed the error to: instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: idX25.1
exporting instance: "/Applications/Racket v7.0/share/pkgs/web-server-lib/web-server/http/cookie.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/web-server-lib/web-server/http/xexpr.rkt"
I’ve been chasing it from library to library, but I can’t get rid of it.
what’s the difference between clean and fast-clean
@philip.mcgrath have you just tried running raco setup
without any arguments?
I’ve done raco setup --fast-clean && raco setup
@soegaard2 "—fast-clean : Like —clean, but non-bootstrapping (can fail)"
@lexi.lambda I just ran raco setup
with no arguments, and the error from my program changed to: instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: idY9.1
exporting instance: "/Applications/Racket v7.0/share/pkgs/web-server-lib/web-server/lang/web-cells.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/web-server-lib/web-server/lang/abort-resume.rkt"
It does seem that the “possibly” part of the error message is not the right explanation, then. :)
IIRC that’s where the error was after raco setup --fast-clean && raco setup
, too, but doing it with --fast-clean
took, like, maybe most of an hour, so I’m not eager to repeat that.
Interestingly, I just discovered that I get a different error from racket no-voyant-test.rkt
than ./no-voyant-test.rkt
. This version is: Sapientia:config philip$ racket no-voyant-test.rkt
instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: idX89.1
exporting instance: "/Applications/Racket v7.0/share/pkgs/net-cookies-lib/net/cookies/server.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/web-server-lib/web-server/http/cookie.rkt"
This reminds me of an issue I was having a couple months back, but I can’t remember the details precisely…
“unintialized” an i is missing in the error message
google pointed it out
hah, so it is
That, at least, I know how to fix: https://github.com/racket/racket/pull/2209
It looks like which specific modules will be named in the error I’m getting is not deterministic. With no raco setup
etc. in between, I can get, for example: Sapientia:config philip$ ./no-voyant-test.rkt
instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: idY35.1
exporting instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/29/localization.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/19/time.rkt"
Sapientia:config philip$ ./no-voyant-test.rkt
instantiate-linklet: mismatch;
reference to a variable that is unintialized;
possibly, bytecode file needs re-compile because dependencies changed
name: s:string->list
exporting instance: "/Applications/Racket v7.0/share/pkgs/srfi-lite-lib/srfi/13/string.rkt"
importing instance: "/Applications/Racket v7.0/share/pkgs/net-cookies-lib/net/cookies/common.rkt"
I just tried deleting and replacing my Racket installation, and I still get the error.