@@ -4,8 +4,10 @@ A robust tool for managing hierarchical issues with GitHub Projects using the of
44
55## Features
66
7- - ✅ ** Parent/child issue relationships** using GitHub's sub-issues API
7+ - ✅ ** Automates sub-issue creation** - Handles GitHub's complex GraphQL API requirements since sub-issues aren't directly supported in the CLI
8+ - ✅ ** Simplifies hierarchical workflows** - Single command creates both parent and child issues with proper linking
89- ✅ ** Automatic project board linking** with configurable project URLs
10+ - ✅ ** Optional comprehensive logging** - Track operations, debug issues, and monitor performance
911- ✅ ** Environment-based configuration** via ` .env ` files
1012- ✅ ** CLI-based workflow** with comprehensive error handling
1113- ✅ ** Input validation** with whitespace and empty argument checking
@@ -56,6 +58,23 @@ A robust tool for managing hierarchical issues with GitHub Projects using the of
5658 " Implement POST /api/auth/login endpoint with validation"
5759```
5860
61+ ### With Logging Enabled
62+ ``` bash
63+ # Enable logging with INFO level
64+ ENABLE_LOGGING=true LOG_LEVEL=INFO ./gh-issue-manager.sh \
65+ " Implement User Authentication" \
66+ " Add OAuth2 authentication system with JWT tokens" \
67+ " Create Login API Endpoint" \
68+ " Implement POST /api/auth/login endpoint with validation"
69+
70+ # Enable debug logging for troubleshooting
71+ ENABLE_LOGGING=true LOG_LEVEL=DEBUG ./gh-issue-manager.sh \
72+ " Debug Issue Creation" \
73+ " Test issue for debugging purposes" \
74+ " Debug Child Issue" \
75+ " Child issue for testing"
76+ ```
77+
5978## Configuration
6079
6180### Environment Variables (.env)
@@ -65,6 +84,11 @@ PROJECT_URL=https://github.com/orgs/your-org/projects/1
6584
6685# Optional: GitHub token (usually not needed if gh CLI is authenticated)
6786GITHUB_TOKEN=your_personal_access_token
87+
88+ # Optional: Logging configuration
89+ ENABLE_LOGGING=true # Enable/disable logging (default: false)
90+ LOG_LEVEL=INFO # Log level: DEBUG, INFO, WARN, ERROR (default: INFO)
91+ LOG_FILE=./logs/gh-issue-manager.log # Log file path (default: ./logs/gh-issue-manager.log)
6892```
6993
7094### Project Board Setup
@@ -73,6 +97,83 @@ GITHUB_TOKEN=your_personal_access_token
73973 . Copy the project URL to your ` .env ` file
74984 . Issues will be automatically added to the project
7599
100+ ## Logging
101+
102+ The GitHub Issue Manager includes optional comprehensive logging to help with debugging, monitoring, and audit trails.
103+
104+ ### Logging Configuration
105+
106+ Configure logging through environment variables:
107+
108+ ``` bash
109+ # Enable logging (default: false)
110+ ENABLE_LOGGING=true
111+
112+ # Set log level (default: INFO)
113+ LOG_LEVEL=DEBUG # Most verbose: DEBUG, INFO, WARN, ERROR
114+ LOG_LEVEL=INFO # Standard: INFO, WARN, ERROR
115+ LOG_LEVEL=WARN # Warnings and errors only: WARN, ERROR
116+ LOG_LEVEL=ERROR # Errors only: ERROR
117+
118+ # Set log file path (default: ./logs/gh-issue-manager.log)
119+ LOG_FILE=./logs/gh-issue-manager.log
120+ ```
121+
122+ ### Log Levels
123+
124+ - ** DEBUG** - Detailed debugging information including API calls, timing, and internal operations
125+ - ** INFO** - General operational information about successful operations and progress
126+ - ** WARN** - Warning messages for non-critical issues (also output to console)
127+ - ** ERROR** - Critical failures and errors (also output to console)
128+
129+ ### Log Format
130+
131+ ```
132+ [TIMESTAMP] [LEVEL] [FUNCTION] MESSAGE
133+ [2025-01-15 10:30:45] [INFO] [create_issues] Creating parent issue: 'Feature Implementation'
134+ [2025-01-15 10:30:46] [DEBUG] [create_issues] GitHub API call: gh issue create --title...
135+ [2025-01-15 10:30:47] [INFO] [create_issues] Parent issue created: #123
136+ [2025-01-15 10:30:48] [INFO] [create_issues] Execution time: 2.145s
137+ ```
138+
139+ ### Usage Examples
140+
141+ ``` bash
142+ # Basic logging - INFO level
143+ ENABLE_LOGGING=true ./gh-issue-manager.sh " Title" " Body" " Child" " Body"
144+
145+ # Debug logging for troubleshooting
146+ ENABLE_LOGGING=true LOG_LEVEL=DEBUG ./gh-issue-manager.sh " Title" " Body" " Child" " Body"
147+
148+ # Custom log file location
149+ ENABLE_LOGGING=true LOG_FILE=/var/log/github-issues.log ./gh-issue-manager.sh " Title" " Body" " Child" " Body"
150+
151+ # Set in .env file for persistent configuration
152+ echo " ENABLE_LOGGING=true" >> .env
153+ echo " LOG_LEVEL=INFO" >> .env
154+ ./gh-issue-manager.sh " Title" " Body" " Child" " Body"
155+ ```
156+
157+ ### What Gets Logged
158+
159+ - ** Function execution** - Entry, exit, and timing for all major functions
160+ - ** GitHub API operations** - Issue creation, sub-issue linking, project assignments
161+ - ** Performance metrics** - Execution time for each operation and total runtime
162+ - ** Error details** - Comprehensive error information with context
163+ - ** Configuration loading** - Environment and .env file processing
164+ - ** Validation results** - Input validation and dependency checks
165+
166+ ### Log File Management
167+
168+ - ** Automatic directory creation** - Log directory created if it doesn't exist
169+ - ** Append mode** - New executions append to existing log file
170+ - ** Manual rotation** - Rotate logs manually when needed:
171+
172+ ``` bash
173+ # Rotate log file
174+ mv logs/gh-issue-manager.log logs/gh-issue-manager-$( date +%Y%m%d) .log
175+ ```
176+
76177## Error Handling
77178
78179The script includes comprehensive error handling for common scenarios:
@@ -112,6 +213,23 @@ Run the comprehensive test suite:
112213 - Ensure GitHub CLI is authenticated
113214 - Verify project URLs before use
114215
216+ ## Why This Script?
217+
218+ GitHub's CLI (` gh ` ) doesn't natively support sub-issue creation. Without this script, you would need to manually:
219+
220+ 1 . Create parent issue
221+ 2 . Create child issue
222+ 3 . Use GraphQL API directly to link them
223+ 4 . Handle API authentication and error checking
224+ 5 . Manage project board assignments separately
225+
226+ This script automates all these steps in a single command while ensuring:
227+
228+ - ✅ Proper error handling at each stage
229+ - ✅ Input validation and sanitization
230+ - ✅ Environment configuration management
231+ - ✅ Project board integration
232+
115233## Technical Implementation
116234
117235Uses GitHub's GraphQL API with ` sub_issues ` feature flag:
@@ -172,11 +290,24 @@ The script is modularized into testable functions:
172290
173291### Debug Mode
174292
175- Run with verbose output:
293+ Multiple debugging approaches available:
294+
176295``` bash
296+ # Method 1: Enable logging with DEBUG level
297+ ENABLE_LOGGING=true LOG_LEVEL=DEBUG ./gh-issue-manager.sh " Parent" " Body" " Child" " Body"
298+
299+ # Method 2: Shell debug mode
177300set -x # Enable debug mode
178301./gh-issue-manager.sh " Parent" " Body" " Child" " Body"
179302set +x # Disable debug mode
303+
304+ # Method 3: Combined logging and shell debug
305+ set -x
306+ ENABLE_LOGGING=true LOG_LEVEL=DEBUG ./gh-issue-manager.sh " Parent" " Body" " Child" " Body"
307+ set +x
308+
309+ # Check log file for detailed execution trace
310+ cat logs/gh-issue-manager.log
180311```
181312
182313## Contributing
@@ -195,5 +326,3 @@ set +x # Disable debug mode
195326 - Maintain >80% function coverage
196327 - Add both unit and integration tests
197328 - Include error scenario testing
198-
199- ![ GitHub Sub-Issue Relationship] ( https://docs.github.com/assets/cb-138303/images/help/issues/sub-issues.png )
0 commit comments