Documentation ¶
Index ¶
- type ConsoleEncoder
- type CookieFilter
- type DeleteFilter
- type FileWriter
- func (FileWriter) CaddyModule() caddy.ModuleInfo
- func (fw FileWriter) OpenWriter() (io.WriteCloser, error)
- func (fw *FileWriter) Provision(ctx caddy.Context) error
- func (fw FileWriter) String() string
- func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (fw FileWriter) WriterKey() string
- type FilterEncoder
- func (fe FilterEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error
- func (fe FilterEncoder) AddBinary(key string, value []byte)
- func (fe FilterEncoder) AddBool(key string, value bool)
- func (fe FilterEncoder) AddByteString(key string, value []byte)
- func (fe FilterEncoder) AddComplex128(key string, value complex128)
- func (fe FilterEncoder) AddComplex64(key string, value complex64)
- func (fe FilterEncoder) AddDuration(key string, value time.Duration)
- func (fe FilterEncoder) AddFloat32(key string, value float32)
- func (fe FilterEncoder) AddFloat64(key string, value float64)
- func (fe FilterEncoder) AddInt(key string, value int)
- func (fe FilterEncoder) AddInt16(key string, value int16)
- func (fe FilterEncoder) AddInt32(key string, value int32)
- func (fe FilterEncoder) AddInt64(key string, value int64)
- func (fe FilterEncoder) AddInt8(key string, value int8)
- func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error
- func (fe FilterEncoder) AddReflected(key string, value any) error
- func (fe FilterEncoder) AddString(key, value string)
- func (fe FilterEncoder) AddTime(key string, value time.Time)
- func (fe FilterEncoder) AddUint(key string, value uint)
- func (fe FilterEncoder) AddUint16(key string, value uint16)
- func (fe FilterEncoder) AddUint32(key string, value uint32)
- func (fe FilterEncoder) AddUint64(key string, value uint64)
- func (fe FilterEncoder) AddUint8(key string, value uint8)
- func (fe FilterEncoder) AddUintptr(key string, value uintptr)
- func (FilterEncoder) CaddyModule() caddy.ModuleInfo
- func (fe FilterEncoder) Clone() zapcore.Encoder
- func (fe FilterEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
- func (fe FilterEncoder) OpenNamespace(key string)
- func (fe *FilterEncoder) Provision(ctx caddy.Context) error
- func (fe *FilterEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type HashFilter
- type IPMaskFilter
- type JSONEncoder
- type LogEncoderConfig
- type LogFieldFilter
- type NetWriter
- func (NetWriter) CaddyModule() caddy.ModuleInfo
- func (nw NetWriter) OpenWriter() (io.WriteCloser, error)
- func (nw *NetWriter) Provision(ctx caddy.Context) error
- func (nw NetWriter) String() string
- func (nw *NetWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (nw NetWriter) WriterKey() string
- type QueryFilter
- type RegexpFilter
- type RenameFilter
- type ReplaceFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleEncoder ¶
type ConsoleEncoder struct { zapcore.Encoder `json:"-"` LogEncoderConfig }
ConsoleEncoder encodes log entries that are mostly human-readable.
func (ConsoleEncoder) CaddyModule ¶
func (ConsoleEncoder) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*ConsoleEncoder) Provision ¶
func (ce *ConsoleEncoder) Provision(_ caddy.Context) error
Provision sets up the encoder.
func (*ConsoleEncoder) UnmarshalCaddyfile ¶
func (ce *ConsoleEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
console { <common encoder config subdirectives...> }
See the godoc on the LogEncoderConfig type for the syntax of subdirectives that are common to most/all encoders.
type CookieFilter ¶
type CookieFilter struct {
// A list of actions to apply to the cookies.
Actions []cookieFilterAction `json:"actions"`
}
CookieFilter is a Caddy log field filter that filters cookies.
This filter updates the logged HTTP header string to remove, replace or hash cookies containing sensitive data. For instance, it can be used to redact any kind of secrets, such as session IDs.
If several actions are configured for the same cookie name, only the first will be applied.
func (CookieFilter) CaddyModule ¶
func (CookieFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (CookieFilter) Filter ¶
func (m CookieFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field.
func (*CookieFilter) UnmarshalCaddyfile ¶
func (m *CookieFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
func (*CookieFilter) Validate ¶
func (f *CookieFilter) Validate() error
Validate checks that action types are correct.
type DeleteFilter ¶
type DeleteFilter struct{}
DeleteFilter is a Caddy log field filter that deletes the field.
func (DeleteFilter) CaddyModule ¶
func (DeleteFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (DeleteFilter) Filter ¶
func (DeleteFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field.
func (DeleteFilter) UnmarshalCaddyfile ¶
func (DeleteFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type FileWriter ¶
type FileWriter struct { // Filename is the name of the file to write. Filename string `json:"filename,omitempty"` // Roll toggles log rolling or rotation, which is // enabled by default. Roll *bool `json:"roll,omitempty"` // When a log file reaches approximately this size, // it will be rotated. RollSizeMB int `json:"roll_size_mb,omitempty"` // Whether to compress rolled files. Default: true RollCompress *bool `json:"roll_gzip,omitempty"` // Whether to use local timestamps in rolled filenames. // Default: false RollLocalTime bool `json:"roll_local_time,omitempty"` // The maximum number of rolled log files to keep. // Default: 10 RollKeep int `json:"roll_keep,omitempty"` // How many days to keep rolled log files. Default: 90 RollKeepDays int `json:"roll_keep_days,omitempty"` }
FileWriter can write logs to files. By default, log files are rotated ("rolled") when they get large, and old log files get deleted, to ensure that the process does not exhaust disk space.
func (FileWriter) CaddyModule ¶
func (FileWriter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (FileWriter) OpenWriter ¶
func (fw FileWriter) OpenWriter() (io.WriteCloser, error)
OpenWriter opens a new file writer.
func (*FileWriter) Provision ¶
func (fw *FileWriter) Provision(ctx caddy.Context) error
Provision sets up the module
func (FileWriter) String ¶
func (fw FileWriter) String() string
func (*FileWriter) UnmarshalCaddyfile ¶
func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
file <filename> { roll_disabled roll_size <size> roll_uncompressed roll_local_time roll_keep <num> roll_keep_for <days> }
The roll_size value has megabyte resolution. Fractional values are rounded up to the next whole megabyte (MiB).
By default, compression is enabled, but can be turned off by setting the roll_uncompressed option.
The roll_keep_for duration has day resolution. Fractional values are rounded up to the next whole number of days.
If any of the roll_size, roll_keep, or roll_keep_for subdirectives are omitted or set to a zero value, then Caddy's default value for that subdirective is used.
func (FileWriter) WriterKey ¶
func (fw FileWriter) WriterKey() string
WriterKey returns a unique key representing this fw.
type FilterEncoder ¶
type FilterEncoder struct { // The underlying encoder that actually // encodes the log entries. Required. WrappedRaw json.RawMessage `json:"wrap,omitempty" caddy:"namespace=caddy.logging.encoders inline_key=format"` // A map of field names to their filters. Note that this // is not a module map; the keys are field names. // // Nested fields can be referenced by representing a // layer of nesting with `>`. In other words, for an // object like `{"a":{"b":0}}`, the inner field can // be referenced as `a>b`. // // The following fields are fundamental to the log and // cannot be filtered because they are added by the // underlying logging library as special cases: ts, // level, logger, and msg. FieldsRaw map[string]json.RawMessage `json:"fields,omitempty" caddy:"namespace=caddy.logging.encoders.filter inline_key=filter"` Fields map[string]LogFieldFilter `json:"-"` // contains filtered or unexported fields }
FilterEncoder can filter (manipulate) fields on log entries before they are actually encoded by an underlying encoder.
func (FilterEncoder) AddArray ¶
func (fe FilterEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error
AddArray is part of the zapcore.ObjectEncoder interface. Array elements do not get filtered.
func (FilterEncoder) AddBinary ¶
func (fe FilterEncoder) AddBinary(key string, value []byte)
AddBinary is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddBool ¶
func (fe FilterEncoder) AddBool(key string, value bool)
AddBool is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddByteString ¶
func (fe FilterEncoder) AddByteString(key string, value []byte)
AddByteString is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddComplex128 ¶
func (fe FilterEncoder) AddComplex128(key string, value complex128)
AddComplex128 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddComplex64 ¶
func (fe FilterEncoder) AddComplex64(key string, value complex64)
AddComplex64 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddDuration ¶
func (fe FilterEncoder) AddDuration(key string, value time.Duration)
AddDuration is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddFloat32 ¶
func (fe FilterEncoder) AddFloat32(key string, value float32)
AddFloat32 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddFloat64 ¶
func (fe FilterEncoder) AddFloat64(key string, value float64)
AddFloat64 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddInt ¶
func (fe FilterEncoder) AddInt(key string, value int)
AddInt is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddInt16 ¶
func (fe FilterEncoder) AddInt16(key string, value int16)
AddInt16 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddInt32 ¶
func (fe FilterEncoder) AddInt32(key string, value int32)
AddInt32 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddInt64 ¶
func (fe FilterEncoder) AddInt64(key string, value int64)
AddInt64 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddInt8 ¶
func (fe FilterEncoder) AddInt8(key string, value int8)
AddInt8 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddObject ¶
func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error
AddObject is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddReflected ¶
func (fe FilterEncoder) AddReflected(key string, value any) error
AddReflected is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddString ¶
func (fe FilterEncoder) AddString(key, value string)
AddString is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddTime ¶
func (fe FilterEncoder) AddTime(key string, value time.Time)
AddTime is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUint ¶
func (fe FilterEncoder) AddUint(key string, value uint)
AddUint is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUint16 ¶
func (fe FilterEncoder) AddUint16(key string, value uint16)
AddUint16 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUint32 ¶
func (fe FilterEncoder) AddUint32(key string, value uint32)
AddUint32 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUint64 ¶
func (fe FilterEncoder) AddUint64(key string, value uint64)
AddUint64 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUint8 ¶
func (fe FilterEncoder) AddUint8(key string, value uint8)
AddUint8 is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) AddUintptr ¶
func (fe FilterEncoder) AddUintptr(key string, value uintptr)
AddUintptr is part of the zapcore.ObjectEncoder interface.
func (FilterEncoder) CaddyModule ¶
func (FilterEncoder) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (FilterEncoder) Clone ¶
func (fe FilterEncoder) Clone() zapcore.Encoder
Clone is part of the zapcore.ObjectEncoder interface. We don't use it as of Oct 2019 (v2 beta 7), I'm not really sure what it'd be useful for in our case.
func (FilterEncoder) EncodeEntry ¶
func (fe FilterEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
EncodeEntry partially implements the zapcore.Encoder interface.
func (FilterEncoder) OpenNamespace ¶
func (fe FilterEncoder) OpenNamespace(key string)
OpenNamespace is part of the zapcore.ObjectEncoder interface.
func (*FilterEncoder) Provision ¶
func (fe *FilterEncoder) Provision(ctx caddy.Context) error
Provision sets up the encoder.
func (*FilterEncoder) UnmarshalCaddyfile ¶
func (fe *FilterEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
filter { wrap <another encoder> fields { <field> <filter> { <filter options> } } }
type HashFilter ¶
type HashFilter struct { }
HashFilter is a Caddy log field filter that replaces the field with the initial 4 bytes of the SHA-256 hash of the content.
func (HashFilter) CaddyModule ¶
func (HashFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*HashFilter) Filter ¶
func (f *HashFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field with the replacement value.
func (*HashFilter) UnmarshalCaddyfile ¶
func (f *HashFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type IPMaskFilter ¶
type IPMaskFilter struct { // The IPv4 mask, as an subnet size CIDR. IPv4MaskRaw int `json:"ipv4_cidr,omitempty"` // The IPv6 mask, as an subnet size CIDR. IPv6MaskRaw int `json:"ipv6_cidr,omitempty"` // contains filtered or unexported fields }
IPMaskFilter is a Caddy log field filter that masks IP addresses.
func (IPMaskFilter) CaddyModule ¶
func (IPMaskFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (IPMaskFilter) Filter ¶
func (m IPMaskFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field.
func (*IPMaskFilter) Provision ¶
func (m *IPMaskFilter) Provision(ctx caddy.Context) error
Provision parses m's IP masks, from integers.
func (*IPMaskFilter) UnmarshalCaddyfile ¶
func (m *IPMaskFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type JSONEncoder ¶
type JSONEncoder struct { zapcore.Encoder `json:"-"` LogEncoderConfig }
JSONEncoder encodes entries as JSON.
func (JSONEncoder) CaddyModule ¶
func (JSONEncoder) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*JSONEncoder) Provision ¶
func (je *JSONEncoder) Provision(_ caddy.Context) error
Provision sets up the encoder.
func (*JSONEncoder) UnmarshalCaddyfile ¶
func (je *JSONEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
json { <common encoder config subdirectives...> }
See the godoc on the LogEncoderConfig type for the syntax of subdirectives that are common to most/all encoders.
type LogEncoderConfig ¶
type LogEncoderConfig struct { MessageKey *string `json:"message_key,omitempty"` LevelKey *string `json:"level_key,omitempty"` TimeKey *string `json:"time_key,omitempty"` NameKey *string `json:"name_key,omitempty"` CallerKey *string `json:"caller_key,omitempty"` StacktraceKey *string `json:"stacktrace_key,omitempty"` LineEnding *string `json:"line_ending,omitempty"` TimeFormat string `json:"time_format,omitempty"` DurationFormat string `json:"duration_format,omitempty"` LevelFormat string `json:"level_format,omitempty"` }
LogEncoderConfig holds configuration common to most encoders.
func (*LogEncoderConfig) UnmarshalCaddyfile ¶
func (lec *LogEncoderConfig) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile populates the struct from Caddyfile tokens. Syntax:
{ message_key <key> level_key <key> time_key <key> name_key <key> caller_key <key> stacktrace_key <key> line_ending <char> time_format <format> duration_format <format> level_format <format> }
func (*LogEncoderConfig) ZapcoreEncoderConfig ¶
func (lec *LogEncoderConfig) ZapcoreEncoderConfig() zapcore.EncoderConfig
ZapcoreEncoderConfig returns the equivalent zapcore.EncoderConfig. If lec is nil, zap.NewProductionEncoderConfig() is returned.
type LogFieldFilter ¶
LogFieldFilter can filter (or manipulate) a field in a log entry.
type NetWriter ¶
type NetWriter struct { // The address of the network socket to which to connect. Address string `json:"address,omitempty"` // The timeout to wait while connecting to the socket. DialTimeout caddy.Duration `json:"dial_timeout,omitempty"` // contains filtered or unexported fields }
NetWriter implements a log writer that outputs to a network socket. If the socket goes down, it will dump logs to stderr while it attempts to reconnect.
func (NetWriter) CaddyModule ¶
func (NetWriter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (NetWriter) OpenWriter ¶
func (nw NetWriter) OpenWriter() (io.WriteCloser, error)
OpenWriter opens a new network connection.
func (*NetWriter) UnmarshalCaddyfile ¶
UnmarshalCaddyfile sets up the handler from Caddyfile tokens. Syntax:
net <address> { dial_timeout <duration> }
type QueryFilter ¶
type QueryFilter struct {
// A list of actions to apply to the query parameters of the URL.
Actions []queryFilterAction `json:"actions"`
}
QueryFilter is a Caddy log field filter that filters query parameters from a URL.
This filter updates the logged URL string to remove, replace or hash query parameters containing sensitive data. For instance, it can be used to redact any kind of secrets which were passed as query parameters, such as OAuth access tokens, session IDs, magic link tokens, etc.
func (QueryFilter) CaddyModule ¶
func (QueryFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (QueryFilter) Filter ¶
func (m QueryFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field.
func (*QueryFilter) UnmarshalCaddyfile ¶
func (m *QueryFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
func (*QueryFilter) Validate ¶
func (f *QueryFilter) Validate() error
Validate checks that action types are correct.
type RegexpFilter ¶
type RegexpFilter struct { // The regular expression pattern defining what to replace. RawRegexp string `json:"regexp,omitempty"` // The value to use as replacement Value string `json:"value,omitempty"` // contains filtered or unexported fields }
RegexpFilter is a Caddy log field filter that replaces the field matching the provided regexp with the indicated string.
func (RegexpFilter) CaddyModule ¶
func (RegexpFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*RegexpFilter) Filter ¶
func (f *RegexpFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field with the replacement value if it matches the regexp.
func (*RegexpFilter) Provision ¶
func (m *RegexpFilter) Provision(ctx caddy.Context) error
Provision compiles m's regexp.
func (*RegexpFilter) UnmarshalCaddyfile ¶
func (f *RegexpFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type RenameFilter ¶
type RenameFilter struct {
Name string `json:"name,omitempty"`
}
RenameFilter is a Caddy log field filter that renames the field's key with the indicated name.
func (RenameFilter) CaddyModule ¶
func (RenameFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*RenameFilter) Filter ¶
func (f *RenameFilter) Filter(in zapcore.Field) zapcore.Field
Filter renames the input field with the replacement name.
func (*RenameFilter) UnmarshalCaddyfile ¶
func (f *RenameFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type ReplaceFilter ¶
type ReplaceFilter struct {
Value string `json:"value,omitempty"`
}
ReplaceFilter is a Caddy log field filter that replaces the field with the indicated string.
func (ReplaceFilter) CaddyModule ¶
func (ReplaceFilter) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*ReplaceFilter) Filter ¶
func (f *ReplaceFilter) Filter(in zapcore.Field) zapcore.Field
Filter filters the input field with the replacement value.
func (*ReplaceFilter) UnmarshalCaddyfile ¶
func (f *ReplaceFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.