go-micro: github.com/micro/go-micro/debug/log Index | Files | Directories

package log

import "github.com/micro/go-micro/debug/log"

Package log provides debug logging

Index

Package Files

log.go options.go os.go

Variables

var (
    // Default buffer size if any
    DefaultSize = 1024
    // DefaultLog logger
    DefaultLog = NewLog()
    // Default formatter
    DefaultFormat = TextFormat
)

func JSONFormat Uses

func JSONFormat(r Record) string

JSONFormat is a json Format func

func TextFormat Uses

func TextFormat(r Record) string

TextFormat returns text format

type FormatFunc Uses

type FormatFunc func(Record) string

Format is a function which formats the output

type Log Uses

type Log interface {
    // Read reads log entries from the logger
    Read(...ReadOption) ([]Record, error)
    // Write writes records to log
    Write(Record) error
    // Stream log records
    Stream() (Stream, error)
}

Log is debug log interface for reading and writing logs

func NewLog Uses

func NewLog(opts ...Option) Log

type Option Uses

type Option func(*Options)

Option used by the logger

func Format Uses

func Format(f FormatFunc) Option

func Name Uses

func Name(n string) Option

Name of the log

func Size Uses

func Size(s int) Option

Size sets the size of the ring buffer

type Options Uses

type Options struct {
    // Name of the log
    Name string
    // Size is the size of ring buffer
    Size int
    // Format specifies the output format
    Format FormatFunc
}

Options are logger options

func DefaultOptions Uses

func DefaultOptions() Options

DefaultOptions returns default options

type ReadOption Uses

type ReadOption func(*ReadOptions)

ReadOption used for reading the logs

func Count Uses

func Count(c int) ReadOption

Count sets the number of log records to return

func Since Uses

func Since(s time.Time) ReadOption

Since sets the time since which to return the log records

type ReadOptions Uses

type ReadOptions struct {
    // Since what time in past to return the logs
    Since time.Time
    // Count specifies number of logs to return
    Count int
    // Stream requests continuous log stream
    Stream bool
}

ReadOptions for querying the logs

type Record Uses

type Record struct {
    // Timestamp of logged event
    Timestamp time.Time `json:"timestamp"`
    // Metadata to enrich log record
    Metadata map[string]string `json:"metadata"`
    // Value contains log entry
    Message interface{} `json:"message"`
}

Record is log record entry

type Stream Uses

type Stream interface {
    Chan() <-chan Record
    Stop() error
}

Stream returns a log stream

Directories

PathSynopsis
kubernetesPackage kubernetes is a logger implementing (github.com/micro/go-micro/debug/log).Log
memoryPackage memory provides an in memory log buffer
noop

Package log imports 10 packages (graph) and is imported by 20 packages. Updated 2020-01-30. Refresh now. Tools for package owners.