logging

package
v0.0.0-...-65871c1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Info  string = "INFO"
	Debug        = "DEBUG"
	Trace        = "TRACE"
	Error        = "ERROR"
	Warn         = "WARN"
)
View Source
const (
	KeyThread    = "thread"
	KeyClass     = "class"
	KeyLevel     = "level"
	KeyTime      = "time"
	KeyDate      = "date"
	KeyTimestamp = "timestamp"
	KeyMessage   = "msg"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	Level  string
	Thread string
	Class  string

	/* other properties */
	Message string
	// contains filtered or unexported fields
}

Log represents a structured log

func NewLog

func NewLog() *Log

NewLog allocates storage and initializes a Log structure

func Parse

func Parse(raw string) (logs []Log)

Parse parses raw text into structured logs

func (*Log) Get

func (l *Log) Get(key string) (value string, ok bool)

Get returns a the value of key set in the log properties or ok = false if there's no value set for that key

func (*Log) JSON

func (l *Log) JSON() string

JSON serializes the log in JSON format

func (*Log) JSONReader

func (l *Log) JSONReader() io.Reader

func (*Log) Props

func (l *Log) Props() []Property

Props returns a slice of the Log arbitrary key-value properties. It does not contain any of the named properties.

func (*Log) Reader

func (l *Log) Reader() io.Reader

func (*Log) Remove

func (l *Log) Remove(key string) (found bool)

Remove will remove the passed key from the log properties. It returns true if a property with the given key was found and removed.

func (*Log) Reset

func (l *Log) Reset()

Reset resets all log properties to their zero values

func (*Log) Set

func (l *Log) Set(key string, value string) (upsert bool)

Set will upsert the value of passed key in the log properties. It returns false if key was not found and property was added or true if it was upserted.

func (*Log) String

func (l *Log) String() string

func (*Log) Timestamp

func (l *Log) Timestamp() string

Timestamp returns the log timestamp

func (*Log) WriteJSONTo

func (l *Log) WriteJSONTo(buf *bytes.Buffer)

func (*Log) WriteTo

func (l *Log) WriteTo(buf *bytes.Buffer)

type Parser

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

Parser holds the state of input text parsing

func NewParser

func NewParser() (p *Parser)

NewParser allocates storage for a Parser and initializes it with the given string

func (*Parser) Parse

func (p *Parser) Parse(chunk string, logs []Log) []Log

Parse will append the logs parsed in chunk in logs slice and return the slice

func (*Parser) Reset

func (p *Parser) Reset()

Reset resets the Parser to use the given chunk

type Property

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

Property represents an arbitrary key-value pair in a Log

Jump to

Keyboard shortcuts

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