Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance logging and documentation generation #893

Merged
merged 3 commits into from
Oct 21, 2024
Merged

Enhance logging and documentation generation #893

merged 3 commits into from
Oct 21, 2024

Conversation

l50
Copy link
Owner

@l50 l50 commented Oct 21, 2024

Key Changes:

  • Refactored PrettyHandler for improved color support and flexibility
  • Updated docGeneration to use go/packages for more robust parsing
  • Enhanced error handling and logging across multiple packages
  • Improved test coverage for logging and documentation generation

Added:

  • JSON output option for logging
  • Debug logging for file system operations in doc generation
  • Helper functions for common test setup tasks in docGeneration_test.go
  • New OutputType enum to support different logging output formats

Changed:

  • Updated PrettyHandler to support both color and JSON output
  • Refactored CreatePackageDocs to use go/packages for improved parsing
  • Enhanced error handling in various functions, using errors.New() consistently
  • Improved test cases for PrettyHandler and docGeneration
  • Updated LogAndReturnError to use errors.New() for consistency

Removed:

  • Unused code in docGeneration.go, including redundant type info extraction
  • Deprecated outputToFile function in PrettyHandler

l50 added 3 commits October 20, 2024 18:29
**Added:**
- JSONOutput type for structured logging
- Support for multiple output types (Plain, Color, JSON) in PrettyHandler
- Log level filtering in PrettyHandler

**Changed:**
- Improved color handling for different log levels in ColorOutput
- Refactored ConfigureLogger to support multiple handlers
- Updated LogAndReturnError to use errors.New instead of fmt.Errorf
- Split logging functionality into separate files for better organization

**Removed:**
- Dependency on github.com/fatih/color package for colorization
- Unused functions: outputToFile and colorizeBasedOnLevel in PrettyHandler

**Fixed:**
- Removed unused functions to improve code cleanliness and maintainability
**Added:**

- Added the `golang.org/x/tools/go/packages` dependency to `go.mod` for
  improved package loading in docs generation.
- Implemented `formatParams` and `formatResults` functions in
  `docGeneration.go` for better function signature formatting using `go/types`.

**Changed:**

- Refactored `docs/docGeneration.go` to use `packages.Load` instead of
  `parser.ParseDir`, eliminating the need for temporary directories.
- Modified function signatures in `docGeneration.go` to include `go/types`
  information for more accurate documentation.
- Updated error formatting in `dev/mage/mageutils.go` by removing colored
  error messages and using `%w` for error wrapping.

**Removed:**

- Removed temporary directory creation and file copying in documentation
  generation.
- Eliminated dependency on `go/parser` and manual AST parsing in
  `docGeneration.go`.
- Removed `outputToFile` and `colorizeBasedOnLevel` functions from
  `logging/prettyhandler.go`.
- Dropped the `github.com/mattn/go-isatty` dependency from `go.mod` and
  `logging/prettyhandler.go`.
**Added:**
- Enhance CreatePackageDocs with better file system handling
- Add debug logging for file system operations
- Introduce helper functions for common test setup tasks

**Changed:**
- Refactor TestCreatePackageDocs for improved readability
- Update file system setup to use temporary directories
- Modify test cases to use new helper functions

**Removed:**
- Remove unused code in docGeneration.go
- Eliminate redundant type information extraction in createFunctionDoc
@l50-renovate-bot l50-renovate-bot bot added area/dev Changes made to dev resources area/logging Changes made to Logging resources area/go labels Oct 21, 2024
@l50 l50 enabled auto-merge (squash) October 21, 2024 03:19
@l50 l50 merged commit 3fe7738 into main Oct 21, 2024
8 checks passed
@l50 l50 deleted the logging-bug-fixes branch October 21, 2024 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dev Changes made to dev resources area/go area/logging Changes made to Logging resources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant