Skip to content

feat: add JSON structured log target#4

Merged
devfeel merged 7 commits intoaicodefrom
aicode-json-log
Mar 16, 2026
Merged

feat: add JSON structured log target#4
devfeel merged 7 commits intoaicodefrom
aicode-json-log

Conversation

@devfeel
Copy link
Owner

@devfeel devfeel commented Mar 14, 2026

Summary

Add JSON structured log output support for modern logging needs.

Changes

Phase 1: JSON Target

  • Add JSON target (targets/target_json.go)
  • Support file output and stdout/stderr
  • Support prettyPrint option for formatted JSON

Phase 2: Configuration

  • Add JSON config structure (config/json.go)
  • Add JSON target support in YAML parser
  • Add XML config support for JSON targets

Phase 3: Testing

  • Add JSON config tests (config/json_test.go)

Test Results

Item Status
Build ✅ Pass
Test ✅ Pass

Files Changed

  • Added: 3 files (+193 lines)
  • Modified: 3 files

Breaking Changes

None.


🐾 Generated by 小源 (OpenClaw AI Assistant)

root and others added 7 commits March 14, 2026 15:32
- Add go.mod for Go modules dependency management
- Add GitHub Actions workflow (test + lint)
- Add YAML configuration parser with full test coverage
- Add config.yaml example file

Co-authored-by: 小源 <ai@devfeel.com>
- Add JSON target support (targets/target_json.go)
- Add JSON config structure (config/json.go)
- Add JSON config tests (config/json_test.go)
- Update const.go with TargetType_JSON
- Update yaml.go to support JSON target

Co-authored-by: 小源 <ai@devfeel.com>
- innerlogger.go: fmt.Sprint(content) -> fmt.Sprint(content...)
- This fixes the build error: missing ... in args forwarded to print-like function
- layout/layout.go: string(ch) -> strconv.Itoa(ch) to fix build error
  'conversion from int to string yields a string of one rune'
- internal/innerlogger.go: fmt.Sprint(content) -> fmt.Sprint(content...)
- targets/target_file.go: pathExists == false -> pathExists
- internal/innerlogger.go: pathExists == false -> pathExists
- layout/layout.go: remove unused fields isEnd, val
- targets/target_file.go: check WriteString error
- internal/innerlogger.go: check WriteString error
- example/normal/main.go: check StartLogService error
- util/convert/convert.go: check binary.Read error
- util/email/email.go: remove unnecessary fmt.Sprintf
- targets/target_file.go: move defer after error check
- internal/innerlogger.go: move defer after error check
- targets/target_udp.go: move defer after error check
- layout/layout.go: remove unnecessary buf assignment
- logger.go: use ok variable to check map key existence
@devfeel devfeel merged commit 6f84b43 into aicode Mar 16, 2026
2 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.

1 participant