Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
logger/cloudwatch_writer.go,实现基于环境变量启用的cloudWatchWriter,并使用本地awsCLI 执行logs子命令来创建资源与上报日志,以避免额外 Go SDK 依赖。AWS_LOG_GROUP_NAME与AWS_LOG_STREAM_NAME配置时启用,并校验AWS_REGION与awsCLI 可用性,启动时尝试幂等创建日志组与日志流,并使用异步队列+批量上报策略(默认批次/间隔可控)。logger.SetupLogger()中接入 CloudWatch writer:将gin.DefaultWriter/gin.DefaultErrorWriter包装为同时写入原有目标(stdout/stderr 或本地日志文件)与 CloudWatch,从而保留原有本地文件写入行为。README.md环境变量表,添加AWS_REGION、AWS_LOG_GROUP_NAME、AWS_LOG_STREAM_NAME及可选凭证变量说明。Testing
gofmt -w logger/logger.go logger/cloudwatch_writer.go(成功)。go test ./logger(结果为无测试文件,构建通过/正常)。go test ./...(失败,但失败原因与本次改动无关,属于仓库中已有的编译/测试问题,例如缺失嵌入资源web/dist和若干现存编译错误)。go get,但因网络/代理原因无法成功获取依赖,故改为使用awsCLI 的实现以保证可构建性与更小的外部依赖变更。Codex Task