Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

Open-source CLI tools need diagnostic data without sacrificing user privacy. Cloud services like Datadog are inappropriate for this use case.

Implementation

  • Error logger (src/utils/error-logger.ts)

    • Local file-based logging to ~/.tsu/logs/errors.log
    • Automatic sanitization: home paths → ~, secrets → [REDACTED]
    • Enabled by default, opt-out via TSU_ERROR_LOG=false
    • Captures: timestamp, versions, platform, command, error, stack trace
  • Integration

    • Updated git root, git changed commands
    • Enhanced ensureCondition helper with optional logging
    • Exported utilities for library consumers
  • Documentation

    • User guide: configuration, viewing logs, reporting issues
    • Security: privacy guarantees, data sanitization details
    • Contributing: integration patterns for new commands

Usage

import { logError } from '../utils/error-logger.js';

export function myCommand() {
  try {
    // Command logic
  } catch (error) {
    logError(error as Error, 'tsu my command');
    console.error('Error: Something went wrong');
    process.exit(1);
  }
}
# Disable logging
TSU_ERROR_LOG=false tsu git changed

# View logs
cat ~/.tsu/logs/errors.log

Design Rationale

Local-only logging for open-source CLI:

  • No external dependencies, API keys, or accounts
  • Data never leaves user's machine
  • Zero cost, works offline
  • User can inspect/delete logs anytime
  • Trade-off: manual aggregation vs automatic privacy

Warning

GitHub's Secret Scanning detected potential secrets in the added content. We attempted to remediate the issue by updating the code or redacting.

Original prompt

I think datadog as a webapp maybe isn't a good solution for my project. What would be a good way of logging when users experience errors etc for an open source cli program


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 28, 2025 16:25
- Add privacy-focused local error logging utility
- Automatically sanitizes sensitive data (paths, secrets)
- Enabled by default, opt-out via TSU_ERROR_LOG=false
- Logs stored locally in ~/.tsu/logs/errors.log
- Integrate error logging into git commands
- Export error logging utilities for library users
- Add comprehensive documentation for error logging
- Update contributing guide with error logging best practices

Co-authored-by: bestdan <2766380+bestdan@users.noreply.github.com>
Co-authored-by: bestdan <2766380+bestdan@users.noreply.github.com>
- Remove redundant inline comment in getErrorLogConfig
- Fix comment accuracy: "tilde notation" vs "relative paths"
- Fix regex/condition mismatch for secret redaction (30+ chars)
- Fix JSDoc: "enabled by default" vs "opt-in"
- Update docs: clearer terminology for error logging

Co-authored-by: bestdan <2766380+bestdan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add error logging for user experiences in CLI program Add local error logging for CLI diagnostics Dec 28, 2025
Copilot AI requested a review from bestdan December 28, 2025 16:33
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.

2 participants