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

Allow running with debug logging #123

Open
dbnicholson opened this issue Nov 10, 2023 · 5 comments · Fixed by #125
Open

Allow running with debug logging #123

dbnicholson opened this issue Nov 10, 2023 · 5 comments · Fixed by #125

Comments

@dbnicholson
Copy link
Member

Sometimes I'd really like to be able to run the daemon with debug logging. The simplest way to do this is to call kolibri.main.initialize(debug=True). Unfortunately, the initialize call is buried a few layers down. @dylanmccall do you have any ideas about the best way to plumb this through?

@dylanmccall
Copy link
Contributor

I like that thought, too! I'd avoid touching the desktop app here, since that's a lot of things.

I was wondering if the KOLIBRI_DEBUG environment variable could affect the behaviour here. It doesn't at the moment, but running initialize(debug=True) does set that environment variable, so it feels like maybe it should work the other way around as well. Maybe we can pitch that upstream. It should amount to a nice little pull request.

With that said, that's kind of ugly since it doesn't map to Kolibri's configuration file, so maybe we really do want a KOLIBRI_LOG=debug kind of thing.

Anyway, with that in place (and we can edit our own kolibri_utils.init_kolibri() to do it), the only thing one would need to do to turn on debug logging is either in flatpak overrides or the system service file from eos-kolibri. I'd probably go for the service file so we can just go systemctl edit dbus-endlessos.Key.Daemon.service and add an Environment= entry.

@dbnicholson
Copy link
Member Author

Agreed. After looking at how to plumb a CLI option all the way through, it didn't seem worth the trouble. Untested PR handling KOLIBRI_DEBUG coming.

dbnicholson added a commit that referenced this issue Nov 11, 2023
If the `KOLIBRI_DEBUG` environment variable is set to a truthy value,
pass `debug=True` to the Kolibri initialization routine. This enables
debug logging and the Django debug mode. This is roughly equivalent to
how `kolibri start` works since it treats `KOLIBRI_DEBUG` as equivalent
to the `--debug` CLI option.

Fixes: #123
@dbnicholson
Copy link
Member Author

While the systemd Environment is a start, we also need to patch eos-kolibri to pass the variable through flatpak run. Shouldn't be hard, though.

dbnicholson added a commit to endlessm/eos-kolibri that referenced this issue Nov 11, 2023
Soon the flatpak will use the `KOLIBRI_DEBUG` environment variable to
enable debug mode. Pass the environment variable through while
defaulting the value to `false`.

Helps: endlessm/endless-key-flatpak#123
@dylanmccall dylanmccall reopened this Nov 11, 2023
@dylanmccall
Copy link
Contributor

I'll reopen this until we've wrangled a release through the tubes.

@dbnicholson
Copy link
Member Author

This didn't quite work as expected (should have actually tested first). Since the daemon is D-Bus activated, it won't inherit the environment from flatpak run --env. Instead, you have to add an override with flatpak override --env=KOLIBRI_DEBUG=true org.endlessos.Key.Devel. Then I got DEBUG messages from the daemon. That would obviously be sans .Devel for the production flatpak.

For the system daemon case, I believe the change to the wrapper script in endlessm/eos-kolibri#31 + a systemd override will work since the wrapper script is invoked for the D-Bus service. However, it may be unnecessary if you have the flatpak override in place.

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

Successfully merging a pull request may close this issue.

2 participants