Skip to content

feat: implement log file rotation and enhance logging configuration#14

Merged
cfc4n merged 1 commit intomasterfrom
log-file-rotation
Apr 3, 2025
Merged

feat: implement log file rotation and enhance logging configuration#14
cfc4n merged 1 commit intomasterfrom
log-file-rotation

Conversation

@cfc4n
Copy link
Copy Markdown
Member

@cfc4n cfc4n commented Apr 3, 2025

This pull request focuses on enhancing the logging mechanism, updating browser server functionalities, and refining configuration settings.

Logging Enhancements:

  • Added a new import for utils in cli/cmd/root.go to support the new logging functionality.
  • Introduced LogFileName and MaxLogSize constants for log file management in cli/cmd/root.go.
  • Updated the initLogger function to use RotateWriter for log rotation based on the defined size threshold.
  • Added log statements to track the server start and configuration file load in mlsCommandFunc. [1] [2]

Browser Server Updates:

  • Added a new import for time in services/browser.go to handle timeout configurations.
  • Added a new flag CommandLineFlagSecurityWarningsEnabled to the browser server initialization to disable security warnings.
  • Introduced a new PromptEntry for handling browser prompts in services/browser.go.
  • Updated various browser tool descriptions to use only CSS selectors instead of both XPath and CSS selectors. [1] [2] [3] [4]
  • Added a handlePrompt method to process browser prompts.
  • Updated handleClick and handleFill methods to use a timeout context for selector queries. [1] [2]

Configuration Refinements:

  • Renamed CSSTimeout to SelectorQueryTimeout in services/browser_config.go to better reflect its purpose. [1] [2] [3]
  • Updated test cases to reflect the new configuration name in services/browser_test.go.

Utility Additions:

  • Added a new RotateWriter utility in utils/rotewriter.go to handle log rotation based on file size.

These changes collectively improve the logging system, enhance browser server functionalities, and refine configuration settings for better clarity and performance.

@cfc4n cfc4n added the enhancement New feature or request label Apr 3, 2025
@cfc4n cfc4n requested a review from Copilot April 3, 2025 12:18
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 3, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements log file rotation and enhances logging configuration while also updating browser-related timeout settings and minor configuration improvements. Key changes include:

  • Introducing a RotateWriter in utils/rotewriter.go for log rotation.
  • Replacing CSSTimeout with SelectorQueryTimeout across browser config and related functions.
  • Updating logging initialization in cli/cmd/root.go with the new RotateWriter and log rotation constants.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
utils/rotewriter.go New log rotation implementation using RotateWriter.
services/file_system_config.go Trim whitespace from allowed directory paths.
services/browser_test.go Updated comments to reflect the renamed timeout parameter.
services/browser_config.go Renamed CSSTimeout to SelectorQueryTimeout and updated messages.
services/browser.go Updated browser tool configuration and added prompt handling.
cli/cmd/root.go Updated logger initialization to use RotateWriter and log file constants.
Comments suppressed due to low confidence (2)

cli/cmd/root.go:168

  • [nitpick] The variable name 'loger' appears to be a typo; consider renaming it to 'logger' for consistency.
loger.Info().Str("ServerName", MCPServerName).Str("version", GitVersion).Msg("start")

services/browser_config.go:47

  • [nitpick] Consider updating the error message to use consistent capitalization, e.g., 'Selector query timeout must be greater than 0'.
return fmt.Errorf("selector Query timeout must be greater than 0")

@cfc4n cfc4n merged commit b893811 into master Apr 3, 2025
6 checks passed
@cfc4n cfc4n deleted the log-file-rotation branch April 3, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants