package logz import ( "fmt" "git.noahlan.cn/noahlan/ntool/nlog" "github.com/zeromicro/go-zero/core/logx" ) type NLogWriter struct { } func NewWriter() logx.Writer { return &NLogWriter{} } func (w *NLogWriter) Alert(v any) { nlog.Alert(fmt.Sprintf("%s", v)) } func (w *NLogWriter) Close() error { return nlog.GetWriter().Close() } func (w *NLogWriter) Debug(v any, fields ...logx.LogField) { nlog.GetWriter().Debug(v, toNLogField(fields...)...) } func (w *NLogWriter) Error(v any, fields ...logx.LogField) { nlog.GetWriter().Error(v, toNLogField(fields...)...) } func (w *NLogWriter) Info(v any, fields ...logx.LogField) { nlog.GetWriter().Info(v, toNLogField(fields...)...) } func (w *NLogWriter) Severe(v any) { nlog.GetWriter().Severe(v) } func (w *NLogWriter) Slow(v any, fields ...logx.LogField) { nlog.GetWriter().Slow(v, toNLogField(fields...)...) } func (w *NLogWriter) Stack(v any) { nlog.GetWriter().Stack(v) } func (w *NLogWriter) Stat(v any, fields ...logx.LogField) { nlog.GetWriter().Stat(v, toNLogField(fields...)...) } func toNLogField(fields ...logx.LogField) []nlog.LogField { zapFields := make([]nlog.LogField, 0, len(fields)) for _, f := range fields { zapFields = append(zapFields, nlog.Field(f.Key, f.Value)) } return zapFields }