codec

package
v0.0.21-0...-74e3a9f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default timestamp format
	TimeStamp = "2006-01-02T15:04:05.999Z07:00" // time.RFC3339Nano
)

Variables

This section is empty.

Functions

func Register

func Register(codec string, build CodecFunc)

func TimeStampIsValid

func TimeStampIsValid(layout string, skrew time.Duration) bool

Types

type CodecFunc

type CodecFunc func(out io.Writer, opts ...Option) Encoder

type Encoder

type Encoder interface {
	Encode(log.Record) error
}

func NewCodec

func NewCodec(name string, out io.Writer, opts ...Option) Encoder

type Option

type Option func(*Options)

func WithNoColor

func WithNoColor() Option

func WithPrittyPrint

func WithPrittyPrint(indent string) Option

func WithTimestamps

func WithTimestamps(layout string) Option

func WithoutTimestamps

func WithoutTimestamps() Option

type Options

type Options struct {
	// TimeStamp format layout
	// To disable timestamp(s) output: just leave it empty
	// https://pkg.go.dev/time#pkg-constants
	TimeStamp string
	// PrettyPrint indent string
	// To disable - leave it empty
	PrettyPrint string
	// Do NOT colorize output records.
	NoColor bool
}

Options for encoding

func NewOptions

func NewOptions(opts ...Option) Options

func (*Options) Timestamp

func (conf *Options) Timestamp(date time.Time) *Timestamp

type Timestamp

type Timestamp struct {
	Time   time.Time
	Format string
}

Timestamp. NULLable.

func (*Timestamp) MarshalText

func (ts *Timestamp) MarshalText() ([]byte, error)

func (*Timestamp) String

func (ts *Timestamp) String() string

Directories

Path Synopsis
Package buffer provides a pool-allocated byte buffer.
Package buffer provides a pool-allocated byte buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL