tlog

package module
v0.0.0-...-a34dc26 Latest Latest
Warning

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

Go to latest
Published: May 5, 2016 License: Apache-2.0 Imports: 3 Imported by: 4

README

tlog

Raiqub/tlog is a logger with microservices in mind.

Status

Build Status GoDoc

Installation

To install raiqub/tlog library run the following command:

go get gopkg.in/raiqub/tlog.v0

To import this package, add the following line to your code:

import "gopkg.in/raiqub/tlog.v0"

License

raiqub/tlog is made available under the Apache Version 2.0 License.

Documentation

Overview

Package tlog provides logging and tracing targeted to microservices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelText

func LevelText(l Level) string

LevelText returns a text for the severity level code. It returns a empty string if the code is unknown.

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.

func (*TracerNop) AddEntry

func (*TracerNop) AddEntry(Level, string, string, int, error, string, ...string) *TracerEntry

AddEntry does nothing.

Directories

Path Synopsis
Package services provides services that allow logging and tracing targeted to microservices.
Package services provides services that allow logging and tracing targeted to microservices.

Jump to

Keyboard shortcuts

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