output

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldKeyMsg   = "msg"
	FieldKeyLevel = "level"
	FieldKeyTime  = "time"
)

Default key names for the default fields

Variables

View Source
var (
	// UserOut is the customized logrus log used for direct user output
	UserOut = log.New()
	// UserOutFormatter is the specialized formatter for UserOut
	UserOutFormatter = new(TextFormatter)
	// JSONOutput is a bool telling whether we're outputting in json. Set by command-line args.
	JSONOutput = false
)

Functions

func LogSetUp

func LogSetUp()

LogSetUp sets up UserOut and log loggers as needed by ddev

Types

type FieldMap

type FieldMap map[fieldKey]string

FieldMap allows customization of the key names for default fields.

type JSONFormatter

type JSONFormatter struct {
	// TimestampFormat sets the format used for marshaling timestamps.
	TimestampFormat string

	// DisableTimestamp allows disabling automatic timestamps in output
	DisableTimestamp bool

	// FieldMap allows users to customize the names of keys for default fields.
	// As an example:
	// formatter := &JSONFormatter{
	//   	FieldMap: FieldMap{
	// 		 FieldKeyTime: "@timestamp",
	// 		 FieldKeyLevel: "@level",
	// 		 FieldKeyMsg: "@message",
	//    },
	// }
	FieldMap FieldMap

	sync.Once
	// contains filtered or unexported fields
}

JSONFormatter formats logs into parsable json

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *log.Entry) ([]byte, error)

Format renders a single log entry

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors.
	ForceColors bool

	// Force disabling colors.
	DisableColors bool

	// Disable timestamp logging. useful when output is redirected to logging
	// system that already adds timestamps.
	DisableTimestamp bool

	// Enable logging the full timestamp when a TTY is attached instead of just
	// the time passed since beginning of execution.
	FullTimestamp bool

	// TimestampFormat to use for display when a full timestamp is printed
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool

	// QuoteEmptyFields will wrap empty fields in quotes if true
	QuoteEmptyFields bool

	sync.Once
	// contains filtered or unexported fields
}

TextFormatter formats logs into text. This is a specialization of https://github.com/sirupsen/logrus/blob/master/text_formatter.go It's intended to be used for all user-oriented output from ddev

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *log.Entry) ([]byte, error)

Format renders a single log entry. A key named "raw" is discarded here as it's for json consumption.

Jump to

Keyboard shortcuts

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