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

fix: suppress excessive console logs after updating to v2.10.1 #4182

Merged

Conversation

superDingda
Copy link
Contributor

@superDingda superDingda commented Apr 1, 2025


Description

This PR fixes excessive console logging after updating to Wails v2.10.1 Previously, any Go backend function call results were automatically printed to the console, making it difficult to read actual logs. This update suppresses those unnecessary logs unless explicitly enabled.

Fixes #4111.


Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

This fix has been tested on the following platforms:

  • Windows
  • [] macOS
  • Linux (Ubuntu 20.04)

Test Configuration:

# Wails
Version         | v2.10.1
Package Manager | apt    


# System
WARNING: failed to read int from file: open /sys/devices/system/cpu/cpu0/online: no such file or directory
┌──────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                    |
| Version      | 20.04                                     |
| ID           | ubuntu                                    |
| Go Version   | go1.24.1                                  |
| Platform     | linux                                     |
| Architecture | amd64                                     |
| CPU          | 13th Gen Intel(R) Core(TM) i9-13900H      |
| GPU          | SVGA II Adapter (VMware) - Driver: vmwgfx |
| Memory       | 8GB                                       |
└──────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Available | 26.1.3-0ubuntu1~20.04.1 |
| gcc        | build-essential       | Installed | 12.8ubuntu1.1           |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.20-0ubuntu1.2      |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.38.6-0ubuntu0.20.04.1 |
| npm        | npm                   | Installed | 10.9.2                  |
| *nsis      | nsis                  | Available | 3.05-2                  |
| pkg-config | pkg-config            | Installed | 0.29.1-0ubuntu4         |
|                                                                          |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - docker: sudo apt install docker.io
  - nsis: sudo apt install nsis

 SUCCESS  Your system is ready for Wails development!

Steps to reproduce and verify the fix:

  1. Run wails dev on Wails v2.10.1
  2. Observe excessive console logs whenever a frontend call is made to the Go backend.
  3. Apply this fix and rerun wails dev -loglevel Info .
  4. Verify that only expected logs are printed.

Checklist

  • I have updated website/src/pages/changelog.mdx with details of this PR.
  • My code follows the general coding style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.

Summary by CodeRabbit

These updates improve the application's logging behavior, resulting in a cleaner console output and more consistent error reporting.

  • Bug Fixes
    • Fixed excessive console logging following the recent update.
    • Streamlined log level handling to ensure a smoother and more reliable experience.

Copy link
Contributor

coderabbitai bot commented Apr 1, 2025

Walkthrough

The pull request updates the CreateApp function in v2/internal/app/app_dev.go to validate log level settings and streamline the override logic based on command-line flags. It now validates the log level using pkglogger.StringToLogLevel and returns an error if the conversion fails. Additionally, a new section has been added to the changelog in website/src/pages/changelog.mdx to document a fix for excessive console logging, referencing issue #4111.

Changes

File(s) Change Summary
v2/internal/app/app_dev.go Enhanced CreateApp function: Added log level validation using pkglogger.StringToLogLevel, improved error handling, and simplified flag-based log level override logic.
website/src/pages/changelog.mdx Added new "Fixed" section under "Unreleased" documenting a fix for excessive console logging after updating to v2.10.1 by @superDingda (issue #4111).

Sequence Diagram(s)

sequenceDiagram
    participant A as CreateApp
    participant O as appoptions.LogLevel
    participant F as Command-line Flag
    participant L as Logger

    A->>O: Retrieve LogLevel value
    A->>L: Validate LogLevel (pkglogger.StringToLogLevel)
    alt Validation fails
        L-->>A: Return error
        A-->>Caller: Exit with error
    else Validation succeeds
        A->>F: Check for flag-based log level
        alt Flag is set
            A->>L: Assign flag log level
        else
            A->>L: Use appoptions.LogLevel
        end
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Abundant console logs fix ([#4111])

Possibly related PRs

Suggested reviewers

  • leaanthony
  • fbbdev

Poem

In code fields I happily roam,
Fixing logs so they find their home.
I hop through checks with ears so keen,
No stray logs to be seen.
With every tip and line refined,
I nibble bugs and leave woes behind!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7245b5b and 92a25c7.

📒 Files selected for processing (2)
  • v2/internal/app/app_dev.go (3 hunks)
  • website/src/pages/changelog.mdx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
v2/internal/app/app_dev.go (1)
v2/pkg/logger/logger.go (2)
  • LogLevel (9-9)
  • StringToLogLevel (36-42)
🔇 Additional comments (3)
website/src/pages/changelog.mdx (1)

24-25: Appropriate changelog entry for the fix.

The changelog entry correctly documents the fix for excessive console logging after updating to v2.10.1, providing reference to the GitHub issue #4111 and crediting the contributor @superDingda.

v2/internal/app/app_dev.go (2)

49-54: Good improvement in log level validation.

This change adds proper validation for the appoptions.LogLevel by using pkglogger.StringToLogLevel() to convert and validate the log level. Returning an error if the log level is invalid is a good practice that prevents the application from running with unexpected logging behavior.


177-186: Enhanced log level handling from command-line flags.

This improved implementation:

  1. Properly validates the log level using pkglogger.StringToLogLevel()
  2. Returns an error if an invalid log level is provided
  3. Only updates the logger if the new level is different from the current one

This change effectively addresses the excessive console logging issue by ensuring proper validation and conditional application of log levels.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

sonarqubecloud bot commented Apr 8, 2025

@leaanthony
Copy link
Member

Thanks for this! 🙏

@leaanthony leaanthony merged commit ba9ab72 into wailsapp:master Apr 8, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abundant console logs after updating to 2.10
2 participants