content

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogTimeFormat added in v0.2.0

func DefaultLogTimeFormat() string

DefaultLogTimeFormat return the default log time format

func InitDefaultLogTimeFormat added in v0.2.1

func InitDefaultLogTimeFormat(f string)

InitDefaultLogTimeFormat init the global default log time format

func NewError added in v0.2.0

func NewError(err error) error

NewError return a custom error wrap the real error

Types

type Content

type Content struct {
	Level      level.Level `json:"level"`
	Time       *Time       `json:"time,omitempty"`
	Log        string      `json:"log"`
	Error      error       `json:"-"`
	AppendTime bool        `json:"-"`
	Args       []any       `json:"-"`
}

Content the log content info

func NewContent

func NewContent(lvl level.Level, err error, appendTime bool, timeFormat string, log string, args ...any) Content

NewContent return an instance of Content

func NewContentWithTime

func NewContentWithTime(lvl level.Level, err error, t *Time, log string, args ...any) Content

NewContentWithTime return an instance of Content with specified time

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error the custom error for log

func (Error) Error

func (e Error) Error() string

Error implement interface error

func (Error) MarshalText

func (e Error) MarshalText() (text []byte, err error)

MarshalText implement interface encoding.TextMarshaler

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time the custom Time for log

func NewTime

func NewTime(time time.Time) *Time

NewTime convert time.Time to content.Time pointer with default format

func NewTimeWithFormat added in v0.2.0

func NewTimeWithFormat(time time.Time, format string) *Time

NewTimeWithFormat convert time.Time to content.Time pointer with custom format

func (Time) MarshalText

func (t Time) MarshalText() (text []byte, err error)

MarshalText implement interface encoding.TextMarshaler

func (Time) String added in v0.2.0

func (t Time) String() string

String return a formatted time string

func (Time) Time

func (t Time) Time() time.Time

Time convert to time.Time

Jump to

Keyboard shortcuts

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