feat(logging): add Pino logger implementation with Noop fallback#2
Merged
feat(logging): add Pino logger implementation with Noop fallback#2
Conversation
- Implemented NoopLogger class for silent logging when Pino initialization fails. - Created PinoLogger class that utilizes Pino for structured logging. - Added types for Pino logger configuration and metadata. - Updated logging types to include new logger interfaces and metadata structures. refactor(services): remove unused BarrelContentBuilder and FileSystemService - Deleted BarrelContentBuilder and FileSystemService classes as they are no longer needed. test(logging): add unit tests for BarrelContentBuilder and BarrelFileGenerator - Created tests for BarrelContentBuilder to validate export generation. - Added tests for BarrelFileGenerator to ensure correct barrel file creation and updates. - Implemented tests for ExportParser to verify export extraction functionality. chore(tests): update test configurations and improve test structure - Refactored test runner to use fileURLToPath for path resolution. - Created separate tsconfig.test.json for test-specific TypeScript configurations. - Updated webpack configuration for better module resolution and source mapping. chore(env): define environment variables interface for testing - Added IEnvironmentVariables interface to standardize environment variable usage.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a structured logging system with a Pino-based implementation and a Noop fallback, refactors the barrel generation logic into a core module, adds comprehensive unit/integration tests, and updates build/test/linting configurations.
- Add Pino logger (with metrics, filters, composite, factory) and Noop fallback; provide config resolver and types
- Refactor barrel generation into src/core/services with recursive support and improved export parsing
- Expand tests (Jest + Mocha), and update build (webpack/rollup) and linting (ESLint flat config) setup
Reviewed Changes
Copilot reviewed 72 out of 76 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Style: add trailing commas; no functional changes |
| tsconfig.test.json | Add test-specific TS options (NodeNext, noEmit) |
| src/types/index.ts | Export environment variable types |
| src/types/env.ts | Define IEnvironmentVariables interface |
| src/test/suite/index.ts | Use fileURLToPath for ESM-safe path resolution |
| src/test/suite/export.parser.test.ts | Update import to refactored core service |
| src/test/suite/barrel-file.generator.test.ts | Update imports and minor cleanup |
| src/test/suite/barrel-content.builder.test.ts | Update import to refactored core service |
| src/test/runTest.ts | Add Windows skip, ESM-safe path resolution, and options typing |
| src/services/fileSystemService.ts | Remove (replaced by core/service) |
| src/services/barrelContentBuilder.ts | Remove (replaced by core/service) |
| src/logging/types.ts | Introduce logging enums, interfaces, and metrics types |
| src/logging/pino/types.ts | Define Pino-specific configuration types |
| src/logging/pino/logger.ts | Implement Pino-backed ILogger with Noop fallback |
| src/logging/pino/index.ts | Export Pino logger and types |
| src/logging/loggers/noop.ts | Implement Noop logger (pino-like surface) |
| src/logging/loggers/mock.ts | Add test logger capturing calls |
| src/logging/loggers/metrics.ts | Add metrics-wrapping logger |
| src/logging/loggers/index.ts | Barrel for logger implementations/factories |
| src/logging/loggers/filtered.ts | Add filter/sampling wrapper logger |
| src/logging/loggers/factory.ts | Logger factory utilities (composite/pino) |
| src/logging/loggers/composite.ts | Composite logger delegating to multiple loggers |
| src/logging/index.ts | Central exports for logging system |
| src/logging/filters/log-filters.ts | Common log filter utilities |
| src/logging/filters/index.ts | Barrel for filters |
| src/logging/config.ts | Environment-based logger config resolver |
| src/index.ts | Public entry re-exporting extension and core exports |
| src/extension.ts | Register multiple VS Code commands; refactor generation flow |
| src/core/services/index.ts | Barrel for core services |
| src/core/services/file-system.service.ts | Core file system service (TS/TSX-aware) |
| src/core/services/export.parser.ts | Improved export parsing (handles aliases) |
| src/core/services/barrel-file.generator.ts | Core barrel generator with recursive/update modes |
| src/core/services/barrel-content.builder.ts | Build barrel content for files/directories |
| src/core/index.ts | Barrel for core services |
| src/barrelFileGenerator.ts | Remove (replaced by core/services) |
| src/tests/loggers/pino.logger.test.ts | Add tests for PinoLogger behavior |
| src/tests/loggers/noop.logger.test.ts | Add tests for NoopLogger |
| src/tests/loggers/mock.logger.test.ts | Add tests for MockLogger |
| src/tests/loggers/metrics.logger.test.ts | Add tests for MetricsLogger |
| src/tests/loggers/logger.factory.test.ts | Add tests for factory functions |
| src/tests/loggers/logger-config.resolver.test.ts | Add tests for config resolver |
| src/tests/loggers/filtered.logger.test.ts | Add tests for FilteredLogger filters/sampling |
| src/tests/jest.setup.ts | Jest globals setup |
| src/tests/filters/log-filters.test.ts | Add tests for filter utilities |
| src/tests/core/services/export.parser.test.ts | Add export parser tests |
| src/tests/core/services/barrel-file.generator.test.ts | Add barrel generator tests |
| src/tests/core/services/barrel-content.builder.test.ts | Add content builder tests |
| rollup.config.js | Add rollup bundle config for library build |
| package.json | Update extension metadata, scripts, deps; add commands and menus |
| jest.config.cjs | Configure Jest/ts-jest for unit tests |
| eslint.config.mjs | Introduce ESLint flat config |
| README.md | Document new features/usage and test note for Windows |
| LICENSE | Switch to Apache-2.0 |
| CONTRIBUTING.md | Minor formatting/clarity improvements |
| CHANGELOG.md | Minor formatting |
| ARCHITECTURE.md | Update architecture to reflect new core/logging structure |
| .yarnrc.yml | Yarn configuration |
| .yaml-lint.yml | YAML lint rules |
| .prettierrc.yml | Prettier config (YAML) |
| .prettierrc.json | Prettier config (JSON) |
| .prettierignore | Prettier ignore patterns |
| .nvmrc | Pin Node 20 |
| .npmignore | NPM publish ignore rules |
| .markdownlint.yml | Markdown lint rules |
| .jscpd.json | Duplication detector config |
| .github/CODEOWNERS | Code owners file |
| .gitattributes | Set LF and mark dist as generated |
| .eslintrc.json | Legacy ESLint config tweaks |
| .editorconfig | Editor settings |
| .devcontainer/devcontainer.json | Dev container setup |
| .dependency-cruiser.js | Dependency analysis setup |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Removed '**/dist/**' from ESLint ignores. - Updated Jest configuration to ignore '/dist/' in test paths. - Changed main entry point in package.json from './dist/extension.js' to './out/extension.js'. - Updated Rollup output path from 'dist/index.mjs' to 'out/index.mjs'. - Modified runTest.ts to skip tests in headless/CI/Windows environments. - Updated import paths in test files to include '.js' extension. - Added logging to test suite index.ts for better debugging. - Created tsconfig.emit-test.json for test compilation. - Updated tsconfig.json to change output directory from './dist' to './out'. - Added tsconfig.test-suite.json for test suite configuration. - Updated tsconfig.test.json to exclude 'out' directory. - Added webpack.config.cjs for bundling the extension.
…date package name
- Added eslint-plugin-simple-import-sort to ESLint configuration for improved import sorting. - Removed previous import sorting rules in favor of simple-import-sort. - Updated devDependencies in package.json and package-lock.json to include new plugin and updated versions of existing packages. - Deleted rollup.config.js as it is no longer needed. - Cleaned up unnecessary whitespace in various TypeScript files. - Updated webpack configuration to set mode to production and added extension alias for better resolution.
- Deleted the following logger implementations: MetricsLogger, MockLogger, NoopLogger. - Removed related types and interfaces from the logging module. - Updated PinoLogger to handle logging without relying on removed implementations. - Adjusted tests to reflect changes in export handling and logging behavior. - Introduced a test harness for improved testing capabilities.
…and temp directory creation
- Introduced a new barrel structure in `src/core/barrel` to organize exports. - Replaced the old services index with specific barrel exports. - Added `FileSystemService` for handling file operations with comprehensive methods for reading, writing, and managing directories. - Created unit tests for `FileSystemService` to ensure functionality and error handling. - Implemented `ExportParser` for parsing TypeScript exports with tests to validate export extraction. - Added various barrel-related types and constants to improve type safety and maintainability. - Updated import paths across the codebase to reflect the new structure. - Introduced utility functions for array and string manipulation.
refactor: replace barrel file constants with INDEX_FILENAME and DEFAULT_EXPORT_NAME refactor: clean up test files to use expect instead of assert refactor: remove deprecated test harness and migrate to node:test refactor: enhance type definitions with JSDoc comments for clarity fix: update tsconfig to exclude test files and improve module resolution test: add utility functions for string manipulation and their corresponding tests
- Removed Mocha and related type definitions from devDependencies. - Updated test files to use Node's `assert` and `test` modules. - Replaced `expect` assertions with `assert` assertions for consistency. - Created a custom test harness to mimic Jest-like functionality for spies. - Adjusted TypeScript configuration for test suite compatibility with Node's module system.
… and remove redundant code
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.
refactor(services): remove unused BarrelContentBuilder and FileSystemService
test(logging): add unit tests for BarrelContentBuilder and BarrelFileGenerator
chore(tests): update test configurations and improve test structure
chore(env): define environment variables interface for testing