jsonlog

package
v1.9.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONLog

type JSONLog struct {
	// Log is the log message
	Log string `json:"log,omitempty"`
	// Stream is the log source
	Stream string `json:"stream,omitempty"`
	// Created is the created timestamp of log
	Created time.Time `json:"time"`
}

JSONLog represents a log message, typically a single entry from a given log stream. JSONLogs can be easily serialized to and from JSON and support custom formatting.

func (*JSONLog) Format

func (jl *JSONLog) Format(format string) (string, error)

Format returns the log formatted according to format If format is nil, returns the log message If format is json, returns the log marshalled in json format By defalut, returns the log with the log time formatted according to format.

func (*JSONLog) MarshalJSON added in v1.3.0

func (mj *JSONLog) MarshalJSON() ([]byte, error)

MarshalJSON marshals the JSONLog.

func (*JSONLog) MarshalJSONBuf added in v1.3.0

func (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error

MarshalJSONBuf marshals the JSONLog and stores the result to a bytes.Buffer.

func (*JSONLog) Reset added in v1.3.0

func (jl *JSONLog) Reset()

Reset resets the log to nil.

type JSONLogs added in v1.9.0

type JSONLogs struct {
	Log     []byte `json:"log,omitempty"`
	Stream  string `json:"stream,omitempty"`
	Created string `json:"time"`

	// json-encoded bytes
	RawAttrs json.RawMessage `json:"attrs,omitempty"`
}

JSONLogs is based on JSONLog. It allows marshalling JSONLog from Log as []byte and an already marshalled Created timestamp.

func (*JSONLogs) MarshalJSONBuf added in v1.9.0

func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error

MarshalJSONBuf is based on the same method from JSONLog It has been modified to take into account the necessary changes.

Jump to

Keyboard shortcuts

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