Repository navigation
feat: add independent format control for file and stderr logging with automatic ANSI code removal - #7
Merged
Conversation
… ANSI code handling Co-authored-by: josecelano <[email protected]>
…d apply rustfmt Co-authored-by: josecelano <[email protected]>
Co-authored-by: josecelano <[email protected]>
Copilot
AI
changed the title
[WIP] Remove ANSI color codes from file logging
feat: add independent format control for file and stderr logging with automatic ANSI code removal
Oct 16, 2025
Member
|
@copilot, the linting workflow is failing The error: We can add the |
Co-authored-by: josecelano <[email protected]>
Contributor
Author
Fixed in commit c7f0b4d by adding |
josecelano
requested changes
Oct 16, 2025
josecelano
left a comment
Member
There was a problem hiding this comment.
@copilot linting workflow is failing:
2025-10-16T20:36:32.760577Z INFO torrust_linting::utils: markdownlint-cli installed successfully
2025-10-16T20:36:32.760608Z INFO markdown: Scanning markdown files...
./docs/contributing/logging-guide.md:66 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- File output: ANSI color code..."]
./docs/user-guide/logging.md:97 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Clean text (no ANSI escape c..."]
./docs/user-guide/logging.md:124 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Colored terminal output for ..."]
./docs/user-guide/logging.md:143 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Structured data (easy to par..."]
2025-10-16T20:36:34.451948Z ERROR markdown: Markdown linting failed. Please fix the issues above.
2025-10-16T20:36:34.452004Z ERROR torrust_linting::cli: Markdown linting failed: Markdown linting failed
Run scripts/lint.sh to make sure linters pass in stable and nigtly toolchains.
Co-authored-by: josecelano <[email protected]>
Contributor
Author
Fixed in commit 3a8e5d7 by adding blank lines around lists in the documentation files. All linters now pass successfully (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck). |
josecelano
marked this pull request as ready for review
October 20, 2025 15:32
Member
|
ACK 0d35398 |
This was referenced Oct 25, 2025
josecelano
added a commit
that referenced
this pull request
Nov 18, 2025
Bug #7: E2E test was creating environment.json at repository root instead of in data/ directory. Root cause: run_create_command was passing working_dir directly to RepositoryFactory.create() instead of working_dir.join("data"). Impact: - E2E tests created ./e2e-full/environment.json at repo root - This caused cspell errors (username in paths) - Files were tracked by git (not in .gitignore) Fix: Pass working_dir.join("data") to repository factory, matching the pattern used in provision controller (Bug #5 fix). This is the same category of bug as #2, #3, and #5 - passing working_dir instead of data_dir to RepositoryFactory.
josecelano
added a commit
that referenced
this pull request
Nov 18, 2025
e2cf68f fix: [#164] standardize all relative paths to use explicit ./ prefix (Jose Celano) 527b6e0 fix: [#174] fix E2E test repository path (Bug #7) (Jose Celano) 9a8c04c refactor: [#174] make TemplateManager per-environment instead of global (Jose Celano) 37abc11 fix: [#174] correct repository factory path in provision controller (Jose Celano) 30903a0 fix: [#174] correct environment directory path generation across all layers (Jose Celano) c85f0b6 refactor: [#174] rename environment to any_env for AnyEnvironmentState (Jose Celano) d65ad30 refactor: [#174] improve imports in ProvisionCommandHandler (Jose Celano) cc5245b refactor: [#174] use PreflightCleanupContext instead of TestContext for E2E preflight cleanup (Jose Celano) b8e5229 refactor: [#174] move state validation from presentation to application layer (Jose Celano) f03b5a4 feat: [#174] implement provision console command with architectural improvements (Jose Celano) 08a5b0b refactor: [#174] extract dependency building methods in ProvisionCommandHandler (Jose Celano) 25fff84 refactor: [#174] replace Repository with RepositoryFactory in constructor (Jose Celano) bf93638 refactor: [#174] remove template renderers from ProvisionCommandHandler constructor (Jose Celano) fa38817 refactor: [#174] inject TemplateManager as global dependency (Jose Celano) b93affb refactor: [#174] remove OpenTofuClient from ProvisionCommandHandler constructor (Jose Celano) b79d7cf refactor: [#174] create AnsibleClient at workflow start instead of in wait_for_readiness (Jose Celano) 71fbb52 refactor: [#174] make ProvisionCommandHandler fields private and clean up tests (Jose Celano) 25c3624 refactor: [#174] remove AnsibleClient from ProvisionCommandHandler constructor (Jose Celano) 8e36cb5 docs: [#174] add issue spec for implementing provision console command (Jose Celano) Pull request description: ## Summary Implements the `provision` console command for the Torrust Tracker Deployer, enabling infrastructure provisioning through the CLI. ## Changes ### New Command Implementation - **Provision Command**: Complete infrastructure provisioning workflow - OpenTofu template rendering - Infrastructure initialization, validation, planning, and application - Instance information retrieval - Ansible template rendering with runtime IP - SSH connectivity verification - Cloud-init completion waiting ### Architecture Improvements - **State Validation Layer**: Moved from presentation to application layer - **Dependency Injection**: Injected `TemplateManager` as global dependency - **Repository Pattern**: Replaced direct `Repository` with `RepositoryFactory` - **Dependency Building**: Extracted methods for creating OpenTofu and Ansible clients ### Code Quality - **Refactored E2E Tests**: Introduced `PreflightCleanupContext` for minimal context in cleanup operations - **Import Improvements**: Simplified imports using short type references - **Variable Naming**: Clear distinction between `any_env` (type-erased) and `environment` (type-safe) ### Testing - ✅ All unit tests passing (1141 tests) - ✅ All integration tests passing - ✅ All E2E tests passing (provision/destroy + configuration) - ✅ Documentation builds successfully ## Remaining Tasks - [x] Manual CLI verification (to be done after PR review) ## Related Issue Closes #174 ACKs for top commit: josecelano: ACK e2cf68f Tree-SHA512: 25dc6753f1c2ad249e8661921f6565ad58e5490c9759876859140452bfade9a761e159a837eadb1ef575d79e03050e7c45fde0e090632465552a9d003f3ff7ca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ Implementation Complete: Independent Format Control for File vs Stderr Logging
This PR implements Option A from issue #5: Independent format control for file and stderr logging outputs with automatic ANSI code handling.
🎯 Changes Completed
Core Implementation:
.with_ansi(false)for file writers.with_ansi(true)for stderr writersNew CLI Arguments:
--log-file-formatcontrols file output format (default: compact, no ANSI)--log-stderr-formatcontrols stderr output format (default: pretty, with ANSI)with_format()method in LoggingBuilderANSI Code Handling:
✅ Test Results
Automated Tests:
Manual Verification:
\x1b) in log files📊 Benefits
Before (Issue):
After (Fixed):
🎨 Usage Examples
Production (default):
Development:
Log Aggregation:
📝 Documentation
Updated:
docs/user-guide/logging.md- Complete user documentationdocs/contributing/logging-guide.md- Developer documentation🔗 Closes
Closes #5
Estimated file size reduction: 15-20% (ANSI codes removed)
Log parsing: Now fully compatible with grep, awk, sed, and other text tools
Backward compatibility: 100% - old API still works via
with_format()Original prompt
Fixes #5
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.