Skip to content

feat: add logging enhancements and listen address flag for SSE mode#11

Merged
cfc4n merged 2 commits intomasterfrom
sse-mode-fix
Mar 30, 2025
Merged

feat: add logging enhancements and listen address flag for SSE mode#11
cfc4n merged 2 commits intomasterfrom
sse-mode-fix

Conversation

@cfc4n
Copy link
Copy Markdown
Member

@cfc4n cfc4n commented Mar 30, 2025

This pull request includes several changes to the cli/cmd package, focusing on enhancing logging, server initialization, and command-line flag handling. The most significant changes are the addition of new imports, updates to the Serve method to improve logging and server setup, and the introduction of a new command-line flag for specifying the listen address.

Improvements to logging and server setup:

  • cli/cmd/moling.go: Added new imports for fmt, os, strings, and time to support enhanced logging and server setup.
  • cli/cmd/moling.go: Updated the Serve method in MoLingServer to use zerolog for improved logging, including detailed startup messages and warnings about the SSE server URL.

Command-line flag handling:

  • cli/cmd/root.go: Added a new persistent flag listen_addr to specify the listen address for SSE mode, with a default value of an empty string indicating the use of STDIO mode.

@cfc4n cfc4n requested a review from Copilot March 30, 2025 12:30
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 30, 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 enhances the logging functionality and server initialization process while introducing a new persistent flag for specifying the listen address for SSE mode.

  • Updates logging in the Serve method with zerolog for detailed startup messages and warnings.
  • Introduces a new persistent flag "listen_addr" to switch between STDIO and SSE modes.

Reviewed Changes

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

File Description
cli/cmd/root.go Adds the persistent flag "listen_addr" for SSE mode configuration.
cli/cmd/moling.go Updates the Serve method for enhanced logging and SSE server setup.
Comments suppressed due to low confidence (2)

cli/cmd/moling.go:100

  • Consider using strings.TrimPrefix instead of strings.Trim to remove the "http://" prefix from s.listenAddr. Using strings.Trim may remove unintended characters.
ltnAddr := fmt.Sprintf("http://%s", strings.Trim(s.listenAddr, "http://"))

cli/cmd/root.go:129

  • [nitpick] The flag description is unclear; consider rewording it to something like: 'Listen address for SSE mode. If empty, STDIO mode will be used.'
rootCmd.PersistentFlags().StringVarP(&mlConfig.ListenAddr, "listen_addr", "l", "", "listen address for SSE mode. default:'', not listen, used STDIO mode.")

@dosubot dosubot bot added the enhancement New feature or request label Mar 30, 2025
… code formatting step

Signed-off-by: cfc4n <cfc4n.cs@gmail.com>
@cfc4n cfc4n merged commit 84fe156 into master Mar 30, 2025
6 checks passed
@cfc4n cfc4n deleted the sse-mode-fix branch March 30, 2025 12:47
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:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants