Proper place to store log file

46 views
Skip to first unread message

Thomas Del Vecchio

unread,
Aug 24, 2020, 2:02:35 PM8/24/20
to Racket Users
Hi everyone!

I'm currently working on some usage logging for a language we're developing. We need to store a persistent file that is shared across a given device (so that the same log file is used regardless of where you are working). Is there a best place to put this file? I'm looking at find-system-path, but am not sure from the documentation if one of these is best for this purpose.

One option I'm considering is in `(collection-file-path (build-path "logging" "user-logs.log") "<my-language>")`, which is just "<path>/<to>/<my-language>/logging/user-logs.log", but I'm unsure whether it's safe to store user data there (especially if we are expecting to have package updates).

Thanks so much!
Thomas

Ben Greenman

unread,
Aug 24, 2020, 2:22:15 PM8/24/20
to Thomas Del Vecchio, Racket Users
On 8/24/20, Thomas Del Vecchio <thomas_de...@brown.edu> wrote:
> Hi everyone!
>
> I'm currently working on some usage logging for a language we're
> developing. We need to store a persistent file that is shared across a
> given device (so that the same log file is used regardless of where you are
>
> working). Is there a best place to put this file? I'm looking at
> find-system-path
> <https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._find-system-path%29%29>,
>
> but am not sure from the documentation if one of these is best for this
> purpose.
>
> One option I'm considering is in `(collection-file-path (build-path
> "logging" "user-logs.log") "<my-language>")`, which is just
> "<path>/<to>/<my-language>/logging/user-logs.log", but I'm unsure whether
> it's safe to store user data there (especially if we are expecting to have
> package updates).
>
> Thanks so much!
> Thomas

Try the `basedir` package. You can ask for a `(writeable-data-file
"user-logs.log" #:program "<my-language>")`.

https://docs.racket-lang.org/basedir/index.html

Thomas Del Vecchio

unread,
Aug 24, 2020, 2:33:07 PM8/24/20
to Racket Users
Thank you!

Hendrik Boom

unread,
Aug 25, 2020, 9:52:51 PM8/25/20
to Racket Users
On Mon, Aug 24, 2020 at 11:02:35AM -0700, Thomas Del Vecchio wrote:
> Hi everyone!
>
> I'm currently working on some usage logging for a language we're
> developing. We need to store a persistent file that is shared across a
> given device (so that the same log file is used regardless of where you are
> working). Is there a best place to put this file? I'm looking at
> find-system-path
> <https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._find-system-path%29%29>,
> but am not sure from the documentation if one of these is best for this
> purpose.

If the log file is to be system-wide, linux has the directory /var/log

-- hendrik
>
> One option I'm considering is in `(collection-file-path (build-path
> "logging" "user-logs.log") "<my-language>")`, which is just
> "<path>/<to>/<my-language>/logging/user-logs.log", but I'm unsure whether
> it's safe to store user data there (especially if we are expecting to have
> package updates).
>
> Thanks so much!
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/bd7203d0-db4c-4e56-a19f-fb4cb58c8625n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages