zero-contrib icon indicating copy to clipboard operation
zero-contrib copied to clipboard

integrate Slog into logx

Open JiChenSSG opened this issue 4 months ago • 0 comments

#325

Greptile Summary

This pull request integrates the new log/slog package from Go 1.21 into the logx module of the zero-contrib project, implementing a SlogWriter struct in logx/slogx/slog.go to adapt the logx.Writer interface for slog usage.

  • Replaced fmt.Sprint with fmt.Sprintf in logx/slogx/slog.go for consistent formatting across all types in log messages
  • Optimized toSlogFields function to create a single slice for all fields, improving efficiency
  • Implemented SlogWriter struct with methods for various log levels (Debug, Error, Info, etc.) using slog
  • Added NewSlogWriter function to create a new logx.Writer instance using slog.Handler

JiChenSSG avatar Sep 28 '24 23:09 JiChenSSG