time

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HookUpdateTime

func HookUpdateTime(v interface{}, msg string) (interface{}, string, error)

Types

type Timer

type Timer interface {
	Time() time.Time
	TimeSet(time.Time)
}

type WithTime

type WithTime struct {
	// contains filtered or unexported fields
}
Example
buf := bytes.Buffer{}

now := time.Date(2022, time.April, 4, 26, 0, 0, 0, time.UTC)
context := exampleWithTime{
	NewWithTime(now),
}

logger := genelog.New(&buf).
	WithContext(context).
	WithFormatter(json.JSON).
	AddHook(HookUpdateTime)

logger.Print("mylog1")
logger.Print("mylog2")

fmt.Println(&buf)
Output:

func NewWithTime

func NewWithTime(t time.Time) *WithTime

func (WithTime) MarshalJSON

func (w WithTime) MarshalJSON() ([]byte, error)

func (WithTime) Time

func (w WithTime) Time() time.Time

func (*WithTime) TimeSet

func (w *WithTime) TimeSet(t time.Time)

func (*WithTime) UnmarshalJSON added in v1.0.11

func (w *WithTime) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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