Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where should we store logs by default? #71

Closed
akumria opened this issue Sep 6, 2021 · 3 comments
Closed

Where should we store logs by default? #71

akumria opened this issue Sep 6, 2021 · 3 comments

Comments

@akumria
Copy link

akumria commented Sep 6, 2021

Working out the best place to store logs is complicated.

If the user is running the program, from the console, I suspect that the right place is stdout / stderr (as appropriate).

If, however, they are running it in a "detached" (background, daemon) mode with no associated console (or via some agent), a more reasonable default would seem to be $XDG_STATE_HOME (see: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).

@samuong
Copy link
Owner

samuong commented Sep 6, 2021

I think what you're saying is fine, but I'm not sure what changes we would need to make to the code in this repo. Is there a specific change you want made to the alpaca binary itself? Or are you talking about the launchd agent (or systemd unit, or other startup script) that launches it?

This code in this repo just starts a proxy server process and writes some output to stdout/err. It's really up to the packager (e.g. for the homebrew formula, rpm/deb package) to decide how to daemonise that process, and capture (and possibly rotate) the logs. This needs to be left to the packagers because a lot of the conventions are platform-specific.

For macOS, there's a launchd agent in the homebrew formula. I don't know much about launchd and when I originally wrote the formula I wasn't able to figure out how to get launchd to expand variables like $XDG_STATE_HOME or even $HOME, so I just pointed the output at /dev/null. Happy to accept a pull request to fix that in https://github.com/samuong/homebrew-alpaca from anyone that knows how.

@marcelocantos
Copy link
Collaborator

Based on github.com/Homebrew/brew/…/service_spec.rb, perhaps you could log to #{HOMEBREW_PREFIX}/var/log/alpaca.log. I don't know how (or whether) HOMEBREW_PREFIX is populated, however.

@samuong
Copy link
Owner

samuong commented Feb 24, 2023

I've updated the homebrew formula so that it sends logs to var/log/alpaca.log, under the homebrew prefix. So on my Macbook, this is /opt/homebrew/var/log/alpaca.log. It's up to other package maintainers to decide how they want to configure the log file location, but this is the default for homebrew users.

@samuong samuong closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants