Documentation
¶
Index ¶
- type FieldAction
- type FieldAnalysis
- type SlogFunction
- type TypeAnalyzer
- func (ta *TypeAnalyzer) AnalyzeField(field parser.FieldInfo) FieldAnalysis
- func (ta *TypeAnalyzer) AnalyzeStruct(structInfo parser.StructInfo) []FieldAnalysis
- func (ta *TypeAnalyzer) GenerateLogStatement(analysis FieldAnalysis, receiverName string) string
- func (ta *TypeAnalyzer) HasLoggableFields(structInfo parser.StructInfo) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldAction ¶
type FieldAction int
FieldAction represents what action to take for a field during logging
const ( // ActionLog means the field should be logged normally ActionLog FieldAction = iota // ActionRedact means the field should be redacted ActionRedact // ActionSkip means the field should be skipped entirely ActionSkip )
type FieldAnalysis ¶
type FieldAnalysis struct {
Field parser.FieldInfo // Original field information
Action FieldAction // What action to take
SlogFunc SlogFunction // Which slog function to use
LogValue string // The value to log (for redacted fields)
}
FieldAnalysis contains the analysis result for a struct field
type SlogFunction ¶
type SlogFunction string
SlogFunction represents the slog function to use for a field
const ( SlogInt64 SlogFunction = "slog.Int64" SlogString SlogFunction = "slog.String" SlogBool SlogFunction = "slog.Bool" SlogFloat64 SlogFunction = "slog.Float64" SlogAny SlogFunction = "slog.Any" )
type TypeAnalyzer ¶
type TypeAnalyzer struct {
// contains filtered or unexported fields
}
TypeAnalyzer analyzes struct fields and determines appropriate slog functions
func NewTypeAnalyzer ¶
func NewTypeAnalyzer(cfg *config.Config) *TypeAnalyzer
NewTypeAnalyzer creates a new TypeAnalyzer with the given configuration
func (*TypeAnalyzer) AnalyzeField ¶
func (ta *TypeAnalyzer) AnalyzeField(field parser.FieldInfo) FieldAnalysis
AnalyzeField analyzes a single field and returns the appropriate analysis
func (*TypeAnalyzer) AnalyzeStruct ¶
func (ta *TypeAnalyzer) AnalyzeStruct(structInfo parser.StructInfo) []FieldAnalysis
AnalyzeStruct analyzes all fields in a struct and returns field analyses
func (*TypeAnalyzer) GenerateLogStatement ¶
func (ta *TypeAnalyzer) GenerateLogStatement(analysis FieldAnalysis, receiverName string) string
GenerateLogStatement generates the slog statement for a field
func (*TypeAnalyzer) HasLoggableFields ¶
func (ta *TypeAnalyzer) HasLoggableFields(structInfo parser.StructInfo) bool
HasLoggableFields checks if a struct has any fields that should be logged
Click to show internal directories.
Click to hide internal directories.