traceID

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 16 Imported by: 3

README

traceID

todo ...

Documentation

Index

Constants

View Source
const (
	LevelDebug Level = 1 << iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelAssert
	LevelComment
	LevelAll = LevelDebug | LevelInfo | LevelWarn | LevelError | LevelFatal | LevelAssert | LevelComment

	FlagOverwrite Flag = 0

	Version uint16 = 1
)

Variables

View Source
var (
	ErrPacketTooShort = errors.New("packet too short")
	ErrHomelessThread = errors.New("homeless thread, use context.AcquireThread() or thread.AcquireThread() to make")
)

Functions

func Broadcast

func Broadcast(message []byte) (err error)

func BroadcastWithTimeout

func BroadcastWithTimeout(message []byte, timeout time.Duration) (err error)

func Decode

func Decode(p []byte, x *Message) error

func Encode

func Encode(ctx *Ctx) []byte

func RegisterBroadcaster

func RegisterBroadcaster(bc Broadcaster)

func ReleaseCtx

func ReleaseCtx(ctx CtxInterface)

func SetDefaultMarshaller

func SetDefaultMarshaller(m Marshaller)

Types

type AssertInterface

type AssertInterface interface {
	DebugAssert(msg string) RecordInterface
	InfoAssert(msg string) RecordInterface
	WarnAssert(msg string) RecordInterface
	ErrorAssert(msg string) RecordInterface
	FatalAssert(msg string) RecordInterface
	DebugAssertIf(cond bool, msg string) RecordInterface
	InfoAssertIf(cond bool, msg string) RecordInterface
	WarnAssertIf(cond bool, msg string) RecordInterface
	ErrorAssertIf(cond bool, msg string) RecordInterface
	FatalAssertIf(cond bool, msg string) RecordInterface
}

type Broadcaster

type Broadcaster interface {
	SetConfig(config *BroadcasterConfig)
	GetConfig() *BroadcasterConfig
	Broadcast(context.Context, []byte) (int, error)
}

type BroadcasterConfig

type BroadcasterConfig struct {
	Handler   string        `json:"handler"`
	Addr      string        `json:"addr"`
	Path      string        `json:"path,omitempty'"`
	HWM       uint          `json:"hwm,omitempty"`
	Ping      uint          `json:"ping,omitempty"`
	PingDelay time.Duration `json:"pingDelay,omitempty"`
	Topic     string        `json:"topic,omitempty"`
}

type BytesContainer

type BytesContainer interface {
	Bytes() []byte
}

type Clock

type Clock interface {
	Now() time.Time
}

type Ctx

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

func NewCtx

func NewCtx() *Ctx

func (*Ctx) AcquireThread

func (c *Ctx) AcquireThread() ThreadInterface

func (*Ctx) AcquireThreadID

func (c *Ctx) AcquireThreadID(id uint32) ThreadInterface

func (*Ctx) Assert

func (c *Ctx) Assert(msg string) RecordInterface

func (*Ctx) AssertIf

func (c *Ctx) AssertIf(cond bool, msg string) RecordInterface

func (*Ctx) Debug

func (c *Ctx) Debug(msg string) RecordInterface

func (*Ctx) DebugAssert

func (c *Ctx) DebugAssert(msg string) RecordInterface

func (*Ctx) DebugAssertIf

func (c *Ctx) DebugAssertIf(cond bool, msg string) RecordInterface

func (*Ctx) DebugIf

func (c *Ctx) DebugIf(cond bool, msg string) RecordInterface

func (*Ctx) Error

func (c *Ctx) Error(msg string) RecordInterface

func (*Ctx) ErrorAssert

func (c *Ctx) ErrorAssert(msg string) RecordInterface

func (*Ctx) ErrorAssertIf

func (c *Ctx) ErrorAssertIf(cond bool, msg string) RecordInterface

func (*Ctx) ErrorIf

func (c *Ctx) ErrorIf(cond bool, msg string) RecordInterface

func (*Ctx) Fatal

func (c *Ctx) Fatal(msg string) RecordInterface

func (*Ctx) FatalAssert

func (c *Ctx) FatalAssert(msg string) RecordInterface

func (*Ctx) FatalAssertIf

func (c *Ctx) FatalAssertIf(cond bool, msg string) RecordInterface

func (*Ctx) FatalIf

func (c *Ctx) FatalIf(cond bool, msg string) RecordInterface

func (*Ctx) Flush

func (c *Ctx) Flush() (err error)

func (*Ctx) GetID

func (c *Ctx) GetID() string

func (*Ctx) Info

func (c *Ctx) Info(msg string) RecordInterface

func (*Ctx) InfoAssert

func (c *Ctx) InfoAssert(msg string) RecordInterface

func (*Ctx) InfoAssertIf

func (c *Ctx) InfoAssertIf(cond bool, msg string) RecordInterface

func (*Ctx) InfoIf

func (c *Ctx) InfoIf(cond bool, msg string) RecordInterface

func (*Ctx) IsDummy

func (c *Ctx) IsDummy() bool

func (*Ctx) ReleaseThread

func (c *Ctx) ReleaseThread(thread ThreadInterface) CtxInterface

func (*Ctx) Reset

func (c *Ctx) Reset() *Ctx

func (*Ctx) SetBroadcastTimeout

func (c *Ctx) SetBroadcastTimeout(timeout time.Duration) CtxInterface

func (*Ctx) SetClock

func (c *Ctx) SetClock(cl Clock) CtxInterface

func (*Ctx) SetFlag

func (c *Ctx) SetFlag(flag Flag, value bool) CtxInterface

func (*Ctx) SetID

func (c *Ctx) SetID(id string) CtxInterface

func (*Ctx) SetLogger

func (c *Ctx) SetLogger(l Logger) CtxInterface

func (*Ctx) SetMarshaller

func (c *Ctx) SetMarshaller(m Marshaller) CtxInterface

func (*Ctx) SetService

func (c *Ctx) SetService(svc string) CtxInterface

func (*Ctx) SetServiceWithStage

func (c *Ctx) SetServiceWithStage(svc, stage string) CtxInterface

func (*Ctx) SetStage

func (c *Ctx) SetStage(stage string) CtxInterface

func (*Ctx) Trace

func (c *Ctx) Trace(mask Level, msg string) RecordInterface

func (*Ctx) TraceIf

func (c *Ctx) TraceIf(cond bool, mask Level, msg string) RecordInterface

func (*Ctx) Warn

func (c *Ctx) Warn(msg string) RecordInterface

func (*Ctx) WarnAssert

func (c *Ctx) WarnAssert(msg string) RecordInterface

func (*Ctx) WarnAssertIf

func (c *Ctx) WarnAssertIf(cond bool, msg string) RecordInterface

func (*Ctx) WarnIf

func (c *Ctx) WarnIf(cond bool, msg string) RecordInterface

func (*Ctx) Watch

func (c *Ctx) Watch(mask Level) CtxInterface

type CtxInterface

type CtxInterface interface {
	AssertInterface
	SetID(string) CtxInterface
	GetID() string
	SetService(string) CtxInterface
	SetServiceWithStage(string, string) CtxInterface
	SetStage(string) CtxInterface
	SetFlag(Flag, bool) CtxInterface
	Watch(Level) CtxInterface
	SetBroadcastTimeout(time.Duration) CtxInterface
	SetClock(Clock) CtxInterface
	SetMarshaller(Marshaller) CtxInterface
	SetLogger(Logger) CtxInterface
	Debug(string) RecordInterface
	Info(string) RecordInterface
	Warn(string) RecordInterface
	Error(string) RecordInterface
	Fatal(string) RecordInterface
	Assert(string) RecordInterface
	Trace(Level, string) RecordInterface
	DebugIf(bool, string) RecordInterface
	InfoIf(bool, string) RecordInterface
	WarnIf(bool, string) RecordInterface
	ErrorIf(bool, string) RecordInterface
	FatalIf(bool, string) RecordInterface
	AssertIf(bool, string) RecordInterface
	TraceIf(bool, Level, string) RecordInterface
	AcquireThread() ThreadInterface
	AcquireThreadID(uint32) ThreadInterface
	ReleaseThread(ThreadInterface) CtxInterface
	IsDummy() bool
	Flush() error
}

func AcquireCtx

func AcquireCtx() CtxInterface

func AcquireCtxWithID

func AcquireCtxWithID(id string) CtxInterface

type CtxPool

type CtxPool struct {
	// contains filtered or unexported fields
}
var (
	CP CtxPool
)

func (*CtxPool) Get

func (p *CtxPool) Get() *Ctx

func (*CtxPool) Put

func (p *CtxPool) Put(ctx *Ctx)

type DummyAssert

type DummyAssert struct{}

func (DummyAssert) DebugAssert

func (t DummyAssert) DebugAssert(string) RecordInterface

func (DummyAssert) DebugAssertIf

func (t DummyAssert) DebugAssertIf(bool, string) RecordInterface

func (DummyAssert) ErrorAssert

func (t DummyAssert) ErrorAssert(string) RecordInterface

func (DummyAssert) ErrorAssertIf

func (t DummyAssert) ErrorAssertIf(bool, string) RecordInterface

func (DummyAssert) FatalAssert

func (t DummyAssert) FatalAssert(string) RecordInterface

func (DummyAssert) FatalAssertIf

func (t DummyAssert) FatalAssertIf(bool, string) RecordInterface

func (DummyAssert) InfoAssert

func (t DummyAssert) InfoAssert(string) RecordInterface

func (DummyAssert) InfoAssertIf

func (t DummyAssert) InfoAssertIf(bool, string) RecordInterface

func (DummyAssert) WarnAssert

func (t DummyAssert) WarnAssert(string) RecordInterface

func (DummyAssert) WarnAssertIf

func (t DummyAssert) WarnAssertIf(bool, string) RecordInterface

type DummyBroadcast

type DummyBroadcast struct{}

func (DummyBroadcast) Broadcast

func (d DummyBroadcast) Broadcast(context.Context, []byte) (int, error)

func (DummyBroadcast) SetConfig

func (d DummyBroadcast) SetConfig(*BroadcasterConfig)

type DummyClock

type DummyClock struct{}

func (DummyClock) Now

func (d DummyClock) Now() time.Time

type DummyCtx

type DummyCtx struct {
	DummyAssert
}

func (DummyCtx) AcquireThread

func (d DummyCtx) AcquireThread() ThreadInterface

func (DummyCtx) AcquireThreadID

func (d DummyCtx) AcquireThreadID(uint32) ThreadInterface

func (DummyCtx) Assert

func (d DummyCtx) Assert(string) RecordInterface

func (DummyCtx) AssertIf

func (d DummyCtx) AssertIf(bool, string) RecordInterface

func (DummyCtx) Debug

func (d DummyCtx) Debug(string) RecordInterface

func (DummyCtx) DebugIf

func (d DummyCtx) DebugIf(bool, string) RecordInterface

func (DummyCtx) Error

func (d DummyCtx) Error(string) RecordInterface

func (DummyCtx) ErrorIf

func (d DummyCtx) ErrorIf(bool, string) RecordInterface

func (DummyCtx) Fatal

func (d DummyCtx) Fatal(string) RecordInterface

func (DummyCtx) FatalIf

func (d DummyCtx) FatalIf(bool, string) RecordInterface

func (DummyCtx) Flush

func (d DummyCtx) Flush() error

func (DummyCtx) GetID

func (d DummyCtx) GetID() string

func (DummyCtx) Info

func (DummyCtx) InfoIf

func (d DummyCtx) InfoIf(bool, string) RecordInterface

func (DummyCtx) IsDummy

func (d DummyCtx) IsDummy() bool

func (DummyCtx) ReleaseThread

func (d DummyCtx) ReleaseThread(ThreadInterface) CtxInterface

func (DummyCtx) SetBroadcastTimeout

func (d DummyCtx) SetBroadcastTimeout(time.Duration) CtxInterface

func (DummyCtx) SetClock

func (d DummyCtx) SetClock(Clock) CtxInterface

func (DummyCtx) SetFlag

func (d DummyCtx) SetFlag(Flag, bool) CtxInterface

func (DummyCtx) SetID

func (d DummyCtx) SetID(string) CtxInterface

func (DummyCtx) SetLogger

func (d DummyCtx) SetLogger(Logger) CtxInterface

func (DummyCtx) SetMarshaller

func (d DummyCtx) SetMarshaller(Marshaller) CtxInterface

func (DummyCtx) SetService

func (d DummyCtx) SetService(string) CtxInterface

func (DummyCtx) SetServiceWithStage

func (d DummyCtx) SetServiceWithStage(string, string) CtxInterface

func (DummyCtx) SetStage

func (d DummyCtx) SetStage(string) CtxInterface

func (DummyCtx) Trace

func (DummyCtx) TraceIf

func (d DummyCtx) TraceIf(bool, Level, string) RecordInterface

func (DummyCtx) Warn

func (DummyCtx) WarnIf

func (d DummyCtx) WarnIf(bool, string) RecordInterface

func (DummyCtx) Watch

func (d DummyCtx) Watch(Level) CtxInterface

type DummyListener

type DummyListener struct{}

func (DummyListener) Listen

func (d DummyListener) Listen(context.Context, chan []byte) error

func (DummyListener) SetConfig

func (d DummyListener) SetConfig(*ListenerConfig)

type DummyRecord

type DummyRecord struct{}

func (DummyRecord) Comment

func (r DummyRecord) Comment(string) RecordInterface

func (DummyRecord) CommentIf

func (r DummyRecord) CommentIf(bool, string) RecordInterface

func (DummyRecord) Err

func (DummyRecord) ErrIf

func (DummyRecord) Flush

func (r DummyRecord) Flush() error

func (DummyRecord) Slug

func (DummyRecord) Var

func (r DummyRecord) Var(string, interface{}) RecordInterface

func (DummyRecord) VarIf

func (r DummyRecord) VarIf(bool, string, interface{}) RecordInterface

func (DummyRecord) With

func (r DummyRecord) With(Option, interface{}) RecordInterface

type DummyThread

type DummyThread struct {
	DummyAssert
}

func (DummyThread) AcquireThread

func (t DummyThread) AcquireThread() ThreadInterface

func (DummyThread) AcquireThreadID

func (t DummyThread) AcquireThreadID(uint32) ThreadInterface

func (DummyThread) Assert

func (DummyThread) AssertIf

func (t DummyThread) AssertIf(bool, string) RecordInterface

func (DummyThread) Debug

func (DummyThread) DebugIf

func (t DummyThread) DebugIf(bool, string) RecordInterface

func (DummyThread) Error

func (DummyThread) ErrorIf

func (t DummyThread) ErrorIf(bool, string) RecordInterface

func (DummyThread) Fatal

func (DummyThread) FatalIf

func (t DummyThread) FatalIf(bool, string) RecordInterface

func (DummyThread) Flush

func (t DummyThread) Flush() error

func (DummyThread) GetID

func (t DummyThread) GetID() uint32

func (DummyThread) Info

func (DummyThread) InfoIf

func (DummyThread) ReleaseThread

func (t DummyThread) ReleaseThread(ThreadInterface) ThreadInterface

func (DummyThread) SetID

func (DummyThread) Trace

func (DummyThread) TraceIf

func (DummyThread) Warn

func (DummyThread) WarnIf

type EntryType

type EntryType uint8
const (
	EntryLog EntryType = iota
	EntryChapter
	EntryAcquireThread
	EntryReleaseThread
	EntryStage
)

func (EntryType) String

func (e EntryType) String() string

type Flag

type Flag int

type Level

type Level uint8

func (Level) First

func (l Level) First() Level

func (Level) String

func (l Level) String() string

type Listener

type Listener interface {
	SetConfig(*ListenerConfig)
	GetConfig() *ListenerConfig
	Listen(context.Context, chan []byte) error
}

type ListenerConfig

type ListenerConfig struct {
	Handler string `json:"handler"`
	Addr    string `json:"addr"`
	Path    string `json:"path,omitempty"`
	HWM     uint   `json:"hwm,omitempty"`
	Topic   string `json:"topic,omitempty"`
}

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Print(v ...interface{})
	Println(v ...interface{})
}

type Marshaller

type Marshaller interface {
	Marshal(io.ReadWriter, interface{}, bool) ([]byte, error)
}

type Message

type Message struct {
	Bits    bitset.Bitset
	Version uint16
	ID      string
	Service string
	Rows    []MessageRow
	Buf     []byte
}

func (Message) CheckFlag

func (m Message) CheckFlag(flag Flag) bool

type MessageRow

type MessageRow struct {
	Level    Level
	Type     EntryType
	Time     int64
	ThreadID uint32
	RecordID uint32
	Key      Entry64
	Value    Entry64
}

type Notifier

type Notifier interface {
	SetConfig(*NotifierConfig)
	Notify(context.Context, string) error
}

type NotifierConfig

type NotifierConfig struct {
	Handler  string `json:"handler"`
	Addr     string `json:"addr,omitempty"`
	Channel  string `json:"channel,omitempty"`
	ChatID   string `json:"chatID,omitempty"`
	Username string `json:"username,omitempty"`
	Token    string `json:"token,omitempty"`
	Template string `json:"template"`
	Format   string `json:"format"`
}

type Option

type Option string
const (
	OptionMarshaller Option = "marshaller"
	OptionIndent     Option = "indent"
)

type ProtoContainer

type ProtoContainer interface {
	fmt.GoStringer
	Size() int
	Marshal() ([]byte, error)
	MarshalTo([]byte) (int, error)
	MarshalToSizedBuffer([]byte) (int, error)
	Unmarshal([]byte) error
}

type Record

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

func (Record) Comment

func (r Record) Comment(msg string) RecordInterface

func (Record) CommentIf

func (r Record) CommentIf(cond bool, msg string) RecordInterface

func (Record) Err

func (r Record) Err(err error) RecordInterface

func (*Record) ErrIf

func (r *Record) ErrIf(cond bool, err error) RecordInterface

func (Record) Flush

func (h Record) Flush() (err error)

func (Record) Slug

func (r Record) Slug(slug string) RecordInterface

func (Record) Var

func (r Record) Var(name string, val interface{}) RecordInterface

func (*Record) VarIf

func (r *Record) VarIf(cond bool, name string, val interface{}) RecordInterface

func (Record) With

func (r Record) With(name Option, value interface{}) RecordInterface

type RecordInterface

type RecordInterface interface {
	Slug(string) RecordInterface
	Var(string, interface{}) RecordInterface
	VarIf(bool, string, interface{}) RecordInterface
	With(Option, interface{}) RecordInterface
	Err(error) RecordInterface
	ErrIf(bool, error) RecordInterface
	Comment(string) RecordInterface
	CommentIf(bool, string) RecordInterface
	Flush() error
}

type Thread

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

func (Thread) AcquireThread

func (t Thread) AcquireThread() ThreadInterface

func (Thread) AcquireThreadID

func (t Thread) AcquireThreadID(id uint32) ThreadInterface

func (Thread) Assert

func (t Thread) Assert(msg string) RecordInterface

func (Thread) AssertIf

func (t Thread) AssertIf(cond bool, msg string) RecordInterface

func (Thread) Debug

func (t Thread) Debug(msg string) RecordInterface

func (Thread) DebugAssert

func (t Thread) DebugAssert(msg string) RecordInterface

func (Thread) DebugAssertIf

func (t Thread) DebugAssertIf(cond bool, msg string) RecordInterface

func (Thread) DebugIf

func (t Thread) DebugIf(cond bool, msg string) RecordInterface

func (Thread) Error

func (t Thread) Error(msg string) RecordInterface

func (Thread) ErrorAssert

func (t Thread) ErrorAssert(msg string) RecordInterface

func (Thread) ErrorAssertIf

func (t Thread) ErrorAssertIf(cond bool, msg string) RecordInterface

func (Thread) ErrorIf

func (t Thread) ErrorIf(cond bool, msg string) RecordInterface

func (Thread) Fatal

func (t Thread) Fatal(msg string) RecordInterface

func (Thread) FatalAssert

func (t Thread) FatalAssert(msg string) RecordInterface

func (Thread) FatalAssertIf

func (t Thread) FatalAssertIf(cond bool, msg string) RecordInterface

func (Thread) FatalIf

func (t Thread) FatalIf(cond bool, msg string) RecordInterface

func (Thread) Flush

func (h Thread) Flush() (err error)

func (Thread) GetID

func (t Thread) GetID() uint32

func (Thread) Info

func (t Thread) Info(msg string) RecordInterface

func (Thread) InfoAssert

func (t Thread) InfoAssert(msg string) RecordInterface

func (Thread) InfoAssertIf

func (t Thread) InfoAssertIf(cond bool, msg string) RecordInterface

func (Thread) InfoIf

func (t Thread) InfoIf(cond bool, msg string) RecordInterface

func (Thread) ReleaseThread

func (t Thread) ReleaseThread(thread ThreadInterface) ThreadInterface

func (*Thread) SetID

func (t *Thread) SetID(id uint32) ThreadInterface

func (Thread) Trace

func (t Thread) Trace(mask Level, msg string) RecordInterface

func (Thread) TraceIf

func (t Thread) TraceIf(cond bool, mask Level, msg string) RecordInterface

func (Thread) Warn

func (t Thread) Warn(msg string) RecordInterface

func (Thread) WarnAssert

func (t Thread) WarnAssert(msg string) RecordInterface

func (Thread) WarnAssertIf

func (t Thread) WarnAssertIf(cond bool, msg string) RecordInterface

func (Thread) WarnIf

func (t Thread) WarnIf(cond bool, msg string) RecordInterface

Directories

Path Synopsis
cmd
traced module

Jump to

Keyboard shortcuts

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