Skip to content

Conversation

@VictoriousRaptor
Copy link
Contributor

@VictoriousRaptor VictoriousRaptor commented May 29, 2024

Closes #2317 #2313

Allow users to select log level. Set to "info" by default.

Clip_20250312_195308

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@VictoriousRaptor
Copy link
Contributor Author

Need some help on UI design.
Qs:

  1. Is a dropdown in about page enough?
  2. IMO modifying this option requires restart to take effect. is it acceptable?

@VictoriousRaptor VictoriousRaptor marked this pull request as ready for review March 11, 2025 15:55
@gitstream-cm
Copy link

gitstream-cm bot commented Mar 11, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

📝 Walkthrough

Walkthrough

The changes introduce new logging functionality within the Flow.Launcher application. A method to set the logging level has been added to the Log class, along with a corresponding enum for log levels. The Settings class now includes a property for LogLevel, initialized to LOGLEVEL.INFO. Additionally, the application startup process has been updated to configure the logging level based on user settings. A user interface element has also been added to allow users to select their preferred logging level.

Changes

Files Change Summary
Flow.Launcher/…/Logger/Log.cs Added methods SetLogLevel(LOGLEVEL level), UseDebugLogLevel(), and UseInfoLogLevel(). Introduced LOGLEVEL enum with DEBUG and INFO. Modified logging rule for clarity.
Flow.Launcher/…/UserSettings/Settings.cs Added a new public property LogLevel of type LOGLEVEL, initialized to LOGLEVEL.INFO, with JSON serialization support.
Flow.Launcher/App.xaml.cs Added a line in OnStartupAsync to set the logging level based on _settings.LogLevel.
Flow.Launcher/Languages/en.xaml Introduced new string resources for logging level display: "logLevel", "LogLevelDEBUG", and "LogLevelINFO".
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs Added class LogLevelData extending DropdownDataGeneric<LOGLEVEL>, properties LogLevels and LogLevel, with logic to update the UI upon log level changes.
Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml Added a new card with a ComboBox for selecting the logging level, bound to the LogLevels and LogLevel properties.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Settings
    participant Logger

    App->>Settings: Retrieve LogLevel value
    alt LogLevel == "DEBUG"
        App->>Logger: Call UseDebugLogLevel()
        Logger-->>Logger: Log "Using DEBUG log level."
    else LogLevel == "INFO"
        App->>Logger: Call UseInfoLogLevel()
        Logger-->>Logger: Log "Using INFO log level."
    else Other
        App->>Logger: Log error about unrecognized log level
        App->>Logger: Call UseDebugLogLevel() as fallback
        Logger-->>Logger: Log "Using DEBUG log level."
    end
Loading

Suggested labels

enhancement

Suggested reviewers

  • jjw24

Poem

Oh, what fun in code I see,
A rabbit hops through logs with glee! 🐇
Debug and info now brightly shine,
Settings sing in a neat design.
In this log garden, we frolic and play,
Hop along—it's a bright new day!
🥕 Happy logs, hip-hip hooray!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)

202-202: Consider using a property for LogLevel to maintain consistency.

This new field adds the ability to configure log levels, but it's implemented as a public field rather than as a property with getters and setters like most other settings in this class.

-public string LogLevel = "info";
+public string LogLevel { get; set; } = "info";

Additionally, consider adding XML documentation to explain the purpose of this setting and its valid values (e.g., "debug", "info").

Flow.Launcher.Infrastructure/Logger/Log.cs (1)

66-74: Add log messages when changing log levels.

The new methods provide a good API for switching log levels, but consider adding log messages to record when the log level is changed.

public static void UseDebugLogLevel()
{
    LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
+   Info("Log", "Changed log level to DEBUG");
}

public static void UseInfoLogLevel()
{
    LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
+   Info("Log", "Changed log level to INFO");
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36e10a1 and 44a90e5.

📒 Files selected for processing (4)
  • Flow.Launcher.Infrastructure/Logger/Log.cs (1 hunks)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1 hunks)
  • Flow.Launcher/App.xaml.cs (1 hunks)
  • Flow.Launcher.Infrastructure/Logger/Log.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (2)
Flow.Launcher/App.xaml.cs (1)

125-137: LGTM - Robust implementation for log level selection.

The switch statement correctly handles the different log level settings including a default fallback to debug mode with appropriate error logging for unrecognized values.

One minor improvement suggestion: consider using just nameof(App) for the error message on line 134 since the namespace is already included in the current context.

Flow.Launcher.Infrastructure/Logger/Log.cs (1)

51-59: LGTM - Rule naming is necessary for the new level-switching functionality.

The rule naming allows for finding and modifying specific rules in the configuration.

coderabbitai bot added a commit that referenced this pull request Mar 12, 2025
Docstrings generation was requested by @VictoriousRaptor.

* #2739 (comment)

The following files were modified:

* `Flow.Launcher.Infrastructure/Logger/Log.cs`
* `Flow.Launcher/App.xaml.cs`
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

Note

Generated docstrings for this pull request at #3336

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 22
⚠️ ignored-expect-variant 1
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

Using only_check_changed_files is incompatible with expect.txt.
To accept the items listed, you should add them to allow.txt.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@Jack251970
Copy link
Member

Jack251970 commented Mar 12, 2025

It works fine for me. Now you change log level in general settings page.

@gitstream-cm
Copy link

gitstream-cm bot commented Mar 12, 2025

🥷 Code experts: Jack251970, Yusyuriv

Jack251970 has most 👩‍💻 activity in the files.
Yusyuriv, Jack251970 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Infrastructure/Logger/Log.cs

Activity based on git-commit:

Jack251970
MAR
FEB
JAN
DEC
NOV
OCT

Knowledge based on git-blame:

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Activity based on git-commit:

Jack251970
MAR
FEB 10 additions & 4 deletions
JAN 17 additions & 4 deletions
DEC 1 additions & 1 deletions
NOV
OCT

Knowledge based on git-blame:
Yusyuriv: 14%
Jack251970: 6%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970
MAR
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
Jack251970: 37%
Yusyuriv: 2%

Flow.Launcher/Languages/en.xaml

Activity based on git-commit:

Jack251970
MAR
FEB 10 additions & 7 deletions
JAN 1 additions & 0 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
Yusyuriv: 6%
Jack251970: 2%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Activity based on git-commit:

Jack251970
MAR
FEB 17 additions & 8 deletions
JAN 33 additions & 3 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
Yusyuriv: 83%
Jack251970: 16%

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Activity based on git-commit:

Jack251970
MAR
FEB 1 additions & 1 deletions
JAN 8 additions & 1 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
Yusyuriv: 36%
Jack251970: 2%

To learn more about /:\ gitStream - Visit our Docs

@Jack251970
Copy link
Member

@VictoriousRaptor Check if this can work for you and feel free to merge it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
Flow.Launcher/Languages/en.xaml (1)

107-109: Good addition of log level localization strings.

The new string resources for log level are well-placed in the general settings section of the localization file. Consider adding more log level options like "WARNING", "ERROR", and "FATAL" if those levels are supported in the logging system.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d3fd75 and 66bf046.

📒 Files selected for processing (6)
  • Flow.Launcher.Infrastructure/Logger/Log.cs (2 hunks)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (2 hunks)
  • Flow.Launcher/App.xaml.cs (1 hunks)
  • Flow.Launcher/Languages/en.xaml (1 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (4 hunks)
  • Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Flow.Launcher/App.xaml.cs
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs
  • Flow.Launcher.Infrastructure/Logger/Log.cs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
🔇 Additional comments (3)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (3)

35-35: LGTM! Class definition for LogLevelData looks good.

This follows the pattern of other settings dropdown data classes.


148-150: LGTM! LogLevels property initialization is consistent with other settings.

The initialization of the LogLevels property follows the same pattern as other dropdown settings.


157-157: LGTM! Update to include LogLevels in localization updates.

Properly updated the UpdateEnumDropdownLocalizations method to include the new LogLevels.

@Jack251970
Copy link
Member

Need some help on UI design. Qs:

  1. Is a dropdown in about page enough?
  2. IMO modifying this option requires restart to take effect. is it acceptable?

I find there is no need to restart app to take effect. And I think we can add this in general page.

@VictoriousRaptor VictoriousRaptor merged commit 9b2148f into dev Mar 12, 2025
13 checks passed
@VictoriousRaptor VictoriousRaptor deleted the debug-log-level branch March 12, 2025 12:03
@jjw24 jjw24 added enhancement New feature or request and removed no-pr-activity 5 min review labels Mar 13, 2025
@jjw24 jjw24 added this to the 1.20.0 milestone Mar 13, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support change log level in settings

4 participants