Skip to content

Conversation

@crwood
Copy link
Member

@crwood crwood commented Oct 4, 2022

This PR updates Gridsync's logging system to persist log messages captured from multiple sources to the local filesystem (rather than buffering logs temporarily to memory -- where they would previously be lost between application restarts; see #564). Currently, this PR captures logs from seven different sources/streams. These are:

  1. The Gridsync standard application log
  2. Tahoe-LAFS's stdout stream
  3. Tahoe-LAFS's stderr stream
  4. Tahoe-LAFS's structured (eliot) logs
  5. Magic-Folder's stdout stream
  6. Magic-Folder's stderr stream
  7. Magic-Folder's structured (eliot) logs

By default, captured logs will be written to individual files in the logs subdirectory beneath the Gridsync configuration directory (e.g., ~/.config/gridsync/logs on GNU/Linux) and can be viewed, exported, and optionally (but somewhat poorly) "filtered" using the previously-existing in-application debug log viewer (accessible via the menu -> "Help" -> "View Debug Information..."). The environment variable GRIDSYNC_LOGGING_PATH can be used to control the location of captured logs at runtime (and will be set to .logs during CI/test runs via tox.ini).

Other aspects of logging behavior (such as the maximum log size) can also be controlled by modifying the appropriate "logging" section of config.txt:

[logging]
enabled = true
max_bytes = 10000000

As with all other values in config.txt, these settings can be overridden at runtime via GRIDSYNC_-prefixed environment variables that correspond to the appropriate section/option/value -- for example GRIDSYNC_LOGGING_ENABLED=false to disable logging completed or GRIDSYNC_LOGGING_MAX_BYTES=20000000 to increase the maximum log filesize from 10 MB to 20 MB.

Closes #564

@crwood crwood merged commit 9a71464 into master Oct 4, 2022
@crwood crwood deleted the 564.log-to-disk branch October 4, 2022 02:33
crwood added a commit to PrivateStorageio/PrivateStorageDesktop that referenced this pull request Oct 4, 2022
The "log_maxlen" value of the "debug" section was used to tune the
maximum amount of log messages that would be buffered into the log
deque. With gridsync/gridsync#570, however,
logs are persisted to disk (rather than buffered into memory) and
the "[debug]log_maxlen" value is ignored.
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 this pull request may close these issues.

Buffering logs into memory can make debugging difficult

2 participants