8000 Improve logging and error handling by aknysh · Pull Request #1358 · cloudposse/atmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve logging and error handling #1358

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

Merged
merged 60 commits into from
Jul 1, 2025
Merged

Improve logging and error handling #1358

merged 60 commits into from
Jul 1, 2025

Conversation

aknysh
Copy link
Member
@aknysh aknysh commented Jun 28, 2025

what

  • Improve logging

    • Remove the deprecated logs functions throughout the codebase
    • Only use the structured log functions (log.Info, log.Debug, log.Warn)
  • Improve error handling

    • Add a new Go package errors with all functions and data structures related to error handling in the codebase (all other packages import the errors package and call its functions)
    • Remove all functions from the codebase that would exit the program execution earlier: panic(), log.Fatal(), os.Exit(), and some old Atmos error handling functions
    • In the new errors package, add a function to print errors in Markdown format (if Markdown is configured and TTY is supported), and a function to print errors and exit the program execution
  • Don't process Atmos YAML functions and Go templates in atmos validate stacks

why

  • Improve logging

    • Standardize logs
    • Make it easy to parse and analyze by log aggregators, SIEM tools, or monitoring systems
    • Easier integration with tracing/Telemetry
    • Consistency across logs
    • Better debugging and contextual info
    • Improved querying and filtering
  • Improve error handling

    • Better, standard UI/UX
    • All errors and program exits are handled in just one place, allowing easily configuring the look and feel of all error messages, and adding hooks for Tracing/Telemetry with just a few lines of code/config
    • All early exits from any functions in the codebase (due to errors or other conditions) are now funneled through just one function in the errors package, allowing easier controlling the code execution and exit behavior
  • Don't process Atmos YAML functions and Go templates in atmos validate stacks. YAML functions and Go templates can access backends and clouds, but atmos validate stacks should not require authentication and assuming roles

test

atmos terraform apply --affected --all --dry-run

image

atmos terraform apply component-1 -s nonprods

image

atmos terraform apply component-2 -s prod

image

atmos terraform apply component-1 -s nonprod

image

atmos terraform apply --all --logs-level=Debu

image

Summary by CodeRabbit

  • Refactor

    • Unified and centralized error handling and logging throughout the application, replacing various custom and utility functions with a single standardized error handling mechanism and structured logging.
    • Deprecated and removed old logging and error-printing functions, streamlining output and error reporting.
    • Updated error messages and output formatting for improved clarity and consistency.
    • Reduced redundant debug output for a cleaner user experience.
  • Bug Fixes

    • Improved error reporting for invalid log levels and plan file differences with clearer, Markdown-formatted messages.
  • Tests

    • Updated and added tests to validate new error handling and output formats.
    • Removed obsolete tests for deprecated logging and error functions.
  • Chores

    • Updated dependency google.golang.org/api to v0.239.0.
    • Reorganized and cleaned up import statements across multiple files.
    • Enhanced configuration and test comments for clarity and consistency.
  • Documentation

    • Improved in-code comments and documentation for better maintainability.

@mergify mergify bot added the conflict This PR has conflicts label Jun 29, 2025
@mergify mergify bot removed the conflict This PR has conflicts label Jun 29, 2025
Copy link
mergify bot commented Jun 29, 2025

💥 This pull request now has conflicts. Could you fix it @aknysh? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Jun 29, 2025
@aknysh aknysh added minor New features that do not break anything and removed no-release Do not create a new release (wait for additional code changes) labels Jun 30, 2025
@aknysh aknysh merged commit 9cbd6a3 into main Jul 1, 2025
50 of 51 checks passed
@aknysh aknysh deleted the improve-error-handling branch July 1, 2025 02:21
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Jul 1, 2025
Copy link
github-actions bot commented Jul 1, 2025

These changes were released in v1.182.0.

6FB1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything size/xl Extra large size PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0