logger

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TracePrefix = "[TRACE] "

TracePrefix is the prefix used to print a Terraform trace entry log

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyLog

type EmptyLog struct{}

EmptyLog is an implementation of a Logger that do nothing. It's simmilar to Discard.

func (*EmptyLog) Debugf

func (l *EmptyLog) Debugf(format string, args ...interface{})

Debugf implements a standard Debugf function of Logger interface

func (*EmptyLog) Errorf

func (l *EmptyLog) Errorf(format string, args ...interface{})

Errorf implements a standard Errorf function of Logger interface

func (*EmptyLog) Infof

func (l *EmptyLog) Infof(format string, args ...interface{})

Infof implements a standard Infof function of Logger interface

func (*EmptyLog) Printf

func (l *EmptyLog) Printf(format string, args ...interface{})

Printf implements a standard Printf function of Logger interface

func (*EmptyLog) Warnf

func (l *EmptyLog) Warnf(format string, args ...interface{})

Warnf implements a standard Warnf function of Logger interface

type Level

type Level uint8

Level is the log level type

const (
	LogLevelError Level = iota
	LogLevelWarn
	LogLevelInfo
	LogLevelDebug
	LogLevelTrace

	DefLogLevel = LogLevelInfo
)

Different log level from higher to lower. Lower log levels to the level set won't be displayed. i.e. If LogLevelWarn is set only Warnings and Errors are displayed. DefLogLevel defines the log level to assing by default

type Log

type Log struct {
	Prefix string
	Level  Level
	// contains filtered or unexported fields
}

Log is a basic implementation of the Logger interface that wraps the Go log package and implements Debugf

func DiscardLog

func DiscardLog() *Log

DiscardLog returns a Terranova logger which will discard all the terraform logs.

func NewLog

func NewLog(w io.Writer, prefix string, level Level) *Log

NewLog creates a Log which is an implementation of the Logger interface

func (*Log) Debugf

func (l *Log) Debugf(format string, args ...interface{})

Debugf implements a standard Debugf function of Logger interface

func (*Log) Errorf

func (l *Log) Errorf(format string, args ...interface{})

Errorf implements a standard Errorf function of Logger interface

func (*Log) Infof

func (l *Log) Infof(format string, args ...interface{})

Infof implements a standard Infof function of Logger interface

func (*Log) Printf

func (l *Log) Printf(format string, args ...interface{})

Printf implements a standard Printf function of Logger interface

func (*Log) Warnf

func (l *Log) Warnf(format string, args ...interface{})

Warnf implements a standard Warnf function of Logger interface

type Logger

type Logger interface {
	Printf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Logger interface defines the behaviour of a log instance. Every logger requires to implement these methods to be used by the Middleware

func NewEmptyLog

func NewEmptyLog() Logger

NewEmptyLog create a Terranova Logger that do nothing.

type Middleware

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

Middleware implementations io.Writer to capture all the Terraform logs using the "log" package and send them to the defined logger

func NewMiddleware

func NewMiddleware(l ...Logger) *Middleware

NewMiddleware creates a new instance of Middleware with the Standard Logger (if nil) a the given logger

func (*Middleware) Close

func (m *Middleware) Close()

Close restore the output of the standard logger (used by Terraform) and stop using the Middleware

func (*Middleware) IsEnabled

func (m *Middleware) IsEnabled() bool

IsEnabled returns true if the Middleware is intercepting the log output or not

func (*Middleware) SetLogger

func (m *Middleware) SetLogger(l Logger)

SetLogger sets or changes the logger of the Middleware, which is the logger to send the Terraform output

func (*Middleware) Start

func (m *Middleware) Start()

Start make the Middleware starts intercepting the log output and sending the log entries to the defined logger

func (*Middleware) Write

func (m *Middleware) Write(p []byte) (n int, err error)

Writer captures all the output from Terraform and use the logger to print it out

Jump to

Keyboard shortcuts

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