-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cli): log to ~/.rawback/logs and add the logs command group #81
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
Changes from all commits
e33cf5f
c8ea580
d934668
2159d78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,11 @@ webHost: https://rawback.app | |
| metadata: | ||
| concurrency: 8 | ||
|
|
||
| # Optional. Diagnostic logging, shared with the Desktop app. See "Logging". | ||
| logging: | ||
| level: info | ||
| maxFiles: 3 | ||
|
|
||
| # Required only by `rawback photos upload` | ||
| sftp: | ||
| endpoint: sftp://ftp.rawback.app:23168 | ||
|
|
@@ -427,8 +432,113 @@ Verify the fingerprint through a trusted Rawback channel before pinning it. Do | |
| not delete the upload-state file merely to bypass a host-key mismatch; investigate | ||
| the server or network change first. | ||
|
|
||
| ## Logging | ||
|
|
||
| The CLI and the Desktop app both write diagnostics to `~/.rawback/logs/`, beside | ||
| `config.yml` and `credentials.json`: | ||
|
|
||
| | File | Written by | | ||
| | --------------------------- | ----------------------------- | | ||
| | `cli.log` | `rawback` | | ||
| | `desktop.log` | The Desktop app | | ||
| | `cli.1.log`, `cli.2.log`, … | Rolled archives, newest first | | ||
|
|
||
| Each line is one JSON object, so the file is ordinary JSONL: | ||
|
|
||
| ```bash | ||
| tail -f ~/.rawback/logs/cli.log | jq -c '{time, level, event, ids}' | ||
| jq 'select(.levelValue >= 40)' ~/.rawback/logs/cli.log | ||
|
Comment on lines
+449
to
+450
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These troubleshooting commands target AGENTS.md reference: AGENTS.md:L75-L78 Useful? React with 👍 / 👎. |
||
| ``` | ||
|
|
||
| Every record carries `time`, `level`, `levelValue`, `msg`, the writing app and | ||
| its version, the process ID, and the environment in use. API records add the | ||
| method, path, status and duration, plus the `x-trace-id`, `cf-ray` and | ||
| `x-request-id` values identifying that request server-side — those are the IDs | ||
| worth quoting in a support report. | ||
|
|
||
| ### Levels | ||
|
|
||
| `trace` < `debug` < `info` < `warn` < `error` < `fatal`, plus `silent` to write | ||
| nothing. The default is `info`, at which a run records **every failure and | ||
| nothing else** — browsing the library does not fill the file with one line per | ||
| request. | ||
|
|
||
| - `debug` adds the full request stream and request/response headers. | ||
| - `trace` adds request and response bodies, truncated. | ||
|
|
||
| Secret field and header names — `authorization`, `cookie`, `password`, `token`, | ||
| `refreshToken` and friends — are replaced with `[REDACTED]` at every level, at | ||
| any nesting depth. Credential and authentication GraphQL operations never log | ||
| their variables or body even at `trace`. Query strings are stripped from logged | ||
| URLs, because they carry search terms. | ||
|
|
||
| `trace` still records file paths, album titles and other content from request | ||
| bodies. Turn it on to diagnose something, not as a standing setting. | ||
|
|
||
| ### Configuration | ||
|
|
||
| ```yaml | ||
| logging: | ||
| level: info # trace|debug|info|warn|error|fatal|silent | ||
| file: true # set false to stop writing to disk entirely | ||
| directory: ~/.rawback/logs | ||
| maxFileSize: 10485760 # roll the active file at this many bytes | ||
| maxFiles: 3 # how many files to keep in total, at least 1 | ||
| redact: [] # extra field names to blank out, added to the built-in list | ||
| stderr: false # also mirror records to standard error | ||
| ``` | ||
|
|
||
| `maxFiles` is how many files are kept in total, so the defaults come to about | ||
| 30 MB per app. It must be at least `1` — a rolling log always has a file open, | ||
| so set `file: false` rather than `maxFiles: 0` to stop writing to disk. `redact` only ever adds to the built-in list — a setting that | ||
| could switch redaction off is a setting that leaks tokens. | ||
|
|
||
| Like every other section, `logging` can appear at the top level and inside a | ||
| named environment, where it merges key by key: a shared `level` applies | ||
| everywhere while one environment overrides just the `directory`. | ||
|
|
||
| These environment variables override the file, and the `--log-level` flag | ||
| overrides them: | ||
|
|
||
| | Variable | Effect | | ||
| | ----------------------- | --------------------------------------- | | ||
| | `RAWBACK_LOG_LEVEL` | One of the level names above | | ||
| | `RAWBACK_DEBUG=1` | Shorthand for `RAWBACK_LOG_LEVEL=debug` | | ||
| | `RAWBACK_LOG_FILE=0` | Stop writing to disk | | ||
| | `RAWBACK_LOG_DIR` | Write somewhere other than the default | | ||
| | `RAWBACK_LOG_MAX_SIZE` | Roll at this many bytes | | ||
| | `RAWBACK_LOG_MAX_FILES` | Keep this many rolled archives | | ||
| | `RAWBACK_LOG_STDERR=1` | Also mirror records to standard error | | ||
|
|
||
| An unrecognised value is ignored rather than rejected, so a typo in a shell | ||
| profile cannot stop a command from running. | ||
|
|
||
| ### Reading and clearing | ||
|
|
||
| ```bash | ||
| rawback logs path # where the files are, and how big | ||
| rawback logs show --level warn # the recent records that mattered | ||
| rawback logs purge --yes # delete them, this app and Desktop | ||
| ``` | ||
|
|
||
| `purge` removes only the files listed above and leaves the directory itself | ||
| alone, so pointing `logging.directory` at a folder holding other things is safe. | ||
| See [`rawback logs`](commands.md#rawback-logs) for the full options. | ||
|
|
||
| On Linux and macOS log files are created at mode `0600` inside a `0700` | ||
| directory, the same as `credentials.json`. Windows has no equivalent, so the | ||
| files inherit the directory's permissions there. | ||
|
|
||
| Logging is [pino](https://github.com/pinojs/pino) under the hood, so the output | ||
| is the line-JSON format `pino-pretty` and most log tooling already understands: | ||
| `rawback logs show --json | jq -c .lines[] | pino-pretty` works. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| Whatever the symptom, `rawback logs show --level warn` is the fastest way to see | ||
| what actually failed, including the trace and `cf-ray` IDs to quote when | ||
| reporting it. Re-run the failing command with `-v` first if the log is empty. | ||
|
|
||
| ### Device authorization is temporarily unavailable | ||
|
|
||
| The CLI retries temporary network and server failures while creating the device | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documented command cannot rerun an upload:
photos uploaddefines the directory as the demanded--pathoption and has no positional path, so copying this example produces a validation error instead of collecting verbose upload diagnostics. Change it torawback -v photos upload --path ~/raw.AGENTS.md reference: AGENTS.md:L124-L125
Useful? React with 👍 / 👎.