# logrun-manager **Repository Path**: suyuexinghen28/logrun-manager ## Basic Information - **Project Name**: logrun-manager - **Description**: A powerful command execution tool with automatic logging and comprehensive history management. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-23 - **Last Updated**: 2025-10-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LogRun Manager A powerful command execution tool with automatic logging and comprehensive history management. LogRun captures all command output using the `script` utility and maintains a searchable history of all executions. ## Features - **Automatic Logging**: Every command execution is automatically logged with timestamps - **History Management**: Searchable history with filtering by command, status, and tags - **Smart File Naming**: Log files are automatically named based on command and timestamp - **Status Tracking**: Track success/failure status and execution duration - **Tag Support**: Add custom tags to command executions for organization - **Cleanup Tools**: Automatic cleanup of old log files - **Statistics**: View usage statistics and command frequency - **Cross-Platform**: Works on Linux, macOS, and other Unix-like systems ## Installation ### Quick Start 1. Navigate to the logrun-manager directory: ```bash cd logrun-manager ``` 2. Install the package: ```bash pip install -e . ``` 3. Use the `logrun` command: ```bash logrun --help ``` ## Usage ### Running Commands with Logging Execute any command with automatic logging: ```bash # Run a simple command logrun echo "Hello World" # Run complex commands with arguments logrun gsm test-remote --solver=gcr --gpu=hip --debug --nproc=4 --resolution=1 # Add tags for organization logrun --tag=testing --tag=gpu gsm build --solver=gmres --gpu=cuda ``` ### History Management #### List Recent Executions ```bash # List last 20 executions logrun --list # List last 10 executions logrun list --limit 10 # List only failed executions logrun list --status failed # Filter by command name logrun list --command gsm # Filter by tag logrun list --tag testing ``` #### View Log Content ```bash # Show log content for a specific execution logrun --show-log 5 # Alternative syntax logrun show 5 ``` #### Statistics and Cleanup ```bash # View usage statistics logrun --stats logrun stats # Clean up old logs (default: 30 days) logrun --cleanup logrun cleanup --days 7 # Clean up with confirmation logrun cleanup --days 30 --confirm # Delete a specific log entry by ID logrun -d 5 # Cleanup also removes near-zero logs (<0.05s, e.g., aborted runs) logrun --cleanup ``` ### Log File Format Log files are created with the naming pattern: ``` {command}_{subcommand}-{timestamp}.log ``` Examples: - `gsm_test-remote-20250819_114724.log` - `gsm_list-runs-20250819_114755.log` - `echo_Hello World-20250819_114701.log` ### Command Line Options When the first parameter starts with `--`, it's treated as a logrun management option: ```bash # Management commands (no command execution) logrun --list # List recent logs logrun --show-log 5 # Show specific log logrun --stats # Show statistics logrun --cleanup # Clean old logs logrun -d 5 # Delete log ID 5 and resequence IDs # Command execution with options logrun --tag=test gsm build # Execute gsm build with tag logrun gsm --help # Execute gsm --help (--help goes to gsm) ``` ## Log Entry Information Each log entry contains: - **ID**: Unique identifier for the execution - **Command**: Full command that was executed - **Start Time**: When the command started - **End Time**: When the command completed - **Duration**: How long the command took - **Exit Code**: Command exit status - **Status**: success (exit code 0), failed (non-zero), or running - **Log File**: Path to the detailed log file - **Tags**: Custom tags for organization ## Example Workflow ```bash # Run a test with tags logrun --tag=development --tag=hip gsm test-remote --solver=gcr --gpu=hip --debug # Check recent executions logrun --list # View details of a specific run logrun --show-log 1 # Check statistics logrun --stats # Clean up old logs logrun --cleanup ``` ## Data Storage - **History Database**: `~/.logrun_history.json` in your home directory - **Log Files**: Stored in `logs/` directory (configurable) - **Backup**: Automatic backup created before each update ## Advanced Features ### Filtering and Search ```bash # Find all gsm commands logrun list --command gsm # Find failed executions logrun list --status failed # Find executions with specific tag logrun list --tag gpu # Combine filters logrun list --command gsm --status success --limit 5 ``` ### Log Management ```bash # View statistics logrun stats # Shows: total executions, success/failure rates, top commands # Cleanup with custom retention logrun cleanup --days 14 # Remove logs older than 14 days # Manual log inspection cat logs/gsm_test-remote-20250819_114724.log ``` ## File Structure ``` logrun-manager/ ├── README.md # This file ├── setup.py # Package setup ├── logrun_manager/ # Python package │ ├── __init__.py # Package initialization │ ├── cli.py # CLI interface │ ├── models.py # Data models │ ├── storage.py # Data persistence │ └── runner.py # Command execution └── logs/ # Log files (created automatically) ``` ## Requirements - Python 3.8 or higher - `click` library (installed automatically) - `script` command (part of util-linux, pre-installed on most Linux systems) ## Error Handling - **Missing script command**: Clear error message with installation instructions - **Permission errors**: Graceful handling with helpful messages - **Storage corruption**: Automatic backup and recovery - **Interrupted commands**: Proper cleanup and status tracking ## Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Add tests for new functionality 5. Submit a pull request ## License This project is open source. Feel free to use, modify, and distribute according to your needs.