Documentation ¶
Overview ¶
Package tlog provides logging and tracing targeted to microservices.
Index ¶
- func LevelText(l Level) string
- type Level
- type Tracer
- type TracerEntry
- func (e *TracerEntry) Error() string
- func (mj *TracerEntry) MarshalJSON() ([]byte, error)
- func (mj *TracerEntry) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (e *TracerEntry) String() string
- func (uj *TracerEntry) UnmarshalJSON(input []byte) error
- func (uj *TracerEntry) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type TracerMemory
- type TracerNop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Level ¶
type Level int
Level represents the severity level of an event.
const ( // LevelTrace defines the severity level for fine-grained debugging events. LevelTrace Level = 100 // LevelDebug defines the severity level for debugging events. LevelDebug Level = 200 // LevelInfo defines the severity level for informational events. LevelInfo Level = 300 // LevelWarn defines the severity level for events that indicates potentially // harmful situation. LevelWarn Level = 400 // LevelError defines the severity level for events that indicates failure. LevelError Level = 500 // LevelFatal defines the severity level for very severe errors that leads the // service to abort. LevelFatal Level = 600 )
type Tracer ¶
type Tracer interface { // AddEntry appends a new event to current container. AddEntry( level Level, code, msg string, htStatus int, err error, svcname string, stack ...string, ) *TracerEntry }
A Tracer represents a container that stores event entries for a service.
type TracerEntry ¶
type TracerEntry struct { Code string `bson:"code" json:"code"` Level Level `bson:"level" json:"-"` Service string `bson:"service" json:"-"` Stack []string `bson:"stack" json:"-"` Message string `bson:"msg" json:"message"` HTTPStatus int `bson:"-" json:"status"` InnerError error `bson:"inner" json:"-"` }
A TracerEntry represents a event created by a service.
func (*TracerEntry) Error ¶
func (e *TracerEntry) Error() string
Error returns string representation of current instance error.
func (*TracerEntry) MarshalJSON ¶
func (mj *TracerEntry) MarshalJSON() ([]byte, error)
func (*TracerEntry) MarshalJSONBuf ¶
func (mj *TracerEntry) MarshalJSONBuf(buf fflib.EncodingBuffer) error
func (*TracerEntry) String ¶
func (e *TracerEntry) String() string
String returns string representation of current instance.
func (*TracerEntry) UnmarshalJSON ¶
func (uj *TracerEntry) UnmarshalJSON(input []byte) error
func (*TracerEntry) UnmarshalJSONFFLexer ¶
func (uj *TracerEntry) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
type TracerMemory ¶
type TracerMemory struct { FilterLevel Level Entries []TracerEntry }
A TracerMemory represents a container for service event entries that stores events in-memory.
func NewTracerMemory ¶
func NewTracerMemory(level Level) *TracerMemory
NewTracerMemory creates a new instance of TracerMemory type.
func (*TracerMemory) AddEntry ¶
func (t *TracerMemory) AddEntry( level Level, code, msg string, htStatus int, err error, svcname string, stack ...string, ) *TracerEntry
AddEntry appends a new event to current container.
func (*TracerMemory) FilterEntries ¶
func (t *TracerMemory) FilterEntries(level Level) []TracerEntry
FilterEntries returns event entries where its severity level is greater or equal to specified level.
type TracerNop ¶
type TracerNop struct{}
A TracerNop represents a container for service event entries that stores nothing.
func NewTracerNop ¶
func NewTracerNop() *TracerNop
NewTracerNop creates a new instance of TracerNop type.