log

package
v0.0.0-...-d94cbee Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSmartTerminal

func IsSmartTerminal(w io.Writer) bool

IsSmartTerminal returns true if the writer w is a terminal AND we think that the terminal is smart enough to use VT escape codes etc.

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal returns true if the writer w is a terminal

Types

type BufferPool

type BufferPool struct {
	sync.Pool
}

BufferPool is a type safe sync.Pool of *byte.Buffer, guaranteed to be Reset

func NewBufferPool

func NewBufferPool() *BufferPool

NewBufferPool returns a new bufferPool

func (*BufferPool) Get

func (b *BufferPool) Get() *bytes.Buffer

Get obtains a buffer from the pool

func (*BufferPool) Put

func (b *BufferPool) Put(x *bytes.Buffer)

Put returns a buffer to the pool, resetting it first

type Logger

type Logger interface {
	// Debug is used for debug messages
	Debug(message string)
	// Debugf is used to write a Printf style debug message
	Debugf(format string, args ...interface{})

	// Info is used for normal user facing messages
	Info(message string)
	// Infof is used to write a Printf style user facing status message
	Infof(format string, args ...interface{})

	// StartSpinner starts the loading spinner with a message
	StartSpinner(status string)
	//EndSpinner stops the spinner and displays a checkmark for success or fail state
	EndSpinner(success bool)

	//EndSpinnerMsg works like EndSpinner but changes the msg displayed next to the checkmark
	EndSpinnerMsg(success bool, msg string)

	// Wraps a function with the start and end spinner around
	ActionWithSpinner(msg string, f func() bool)
}

Logger defines the logging interface It is roughly a subset of github.com/kubernetes/klog

type Spinner

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

Spinner is a simple and efficient CLI loading spinner used by kind It is simplistic and assumes that the line length will not change.

func NewSpinner

func NewSpinner(w io.Writer) *Spinner

NewSpinner initializes and returns a new Spinner that will write to w NOTE: w should be os.Stderr or similar, and it should be a Terminal

func (*Spinner) SetPrefix

func (s *Spinner) SetPrefix(prefix string)

SetPrefix sets the prefix to print before the spinner

func (*Spinner) SetSuffix

func (s *Spinner) SetSuffix(suffix string)

SetSuffix sets the suffix to print after the spinner

func (*Spinner) Start

func (s *Spinner) Start()

Start starts the spinner running

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop signals the spinner to stop

func (*Spinner) Write

func (s *Spinner) Write(p []byte) (n int, err error)

Write implements io.Writer, interrupting the spinner and writing to the inner writer

Jump to

Keyboard shortcuts

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