item

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(level sparalog.Level, line string) sparalog.Item

New generates a new item with current timestamp.

func NewError

func NewError(skipStackCalls int, err error) sparalog.Item

NewError generates a new item containing the stack trace. If skipStackCalls = -1 no stacktrace will be produced at all.

func NewErrorf

func NewErrorf(skipStackCalls int, format string, a ...interface{}) sparalog.Item

NewErrorf generate a new log item wrapping an error, as Errorf(). If skipStackCalls = -1 no stacktrace will be produced at all.

Types

type Context

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

Context implements sparalog.Context

func (*Context) AssignContext

func (c *Context) AssignContext(fromCtx sparalog.Context, clone bool)

AssignContext clone a context to current.

func (*Context) Data

func (c *Context) Data() map[string]interface{}

Data returns all the data fields.

func (*Context) Prefix

func (c *Context) Prefix() (format string, tags []string)

Prefix returns the prefix format and tags names.

func (*Context) RenderPrefix

func (c *Context) RenderPrefix() string

RenderPrefix returns a prefix as rendered string.

func (*Context) SetData

func (c *Context) SetData(key string, value interface{})

SetData changes a specific data field.

func (*Context) SetPrefix

func (c *Context) SetPrefix(format string, tags []string)

SetPrefix change the prefix for the context. Tags contains the list of tags names used as params for format.

func (*Context) SetTag

func (c *Context) SetTag(name, value string)

SetTag changes a specific tag.

func (*Context) Tags

func (c *Context) Tags() map[string]string

Tags returns all the tags.

type Item

type Item struct {
	Context
	// contains filtered or unexported fields
}

Item implements sparalog.Item

func (*Item) GenerateStackTrace

func (i *Item) GenerateStackTrace(callsToSkip int)

GenerateStackTrace assign the stack trace of current position to the item.

func (*Item) Level

func (i *Item) Level() sparalog.Level

Level sets the level of the item.

func (*Item) Line

func (i *Item) Line() string

Line gets the desc of the item.

func (*Item) Log

func (i *Item) Log()

Log sends the item to the assigned logger.

func (*Item) SetLine

func (i *Item) SetLine(s string)

SetLine sets de desc of the item.

func (*Item) SetLogger

func (i *Item) SetLogger(logger sparalog.ItemLogger)

SetLogger assigns a logger to the item, for Log() further using.

func (*Item) SetStackTrace

func (i *Item) SetStackTrace(s string)

SetStackTrace assign a stack trace to the item.

func (*Item) StackTrace

func (i *Item) StackTrace() string

StackTrace gets the stack trace of the item.

func (Item) ToString

func (i Item) ToString(timestamp, level bool) string

ToString convert the item to string using a standard format.

Jump to

Keyboard shortcuts

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