Documentation ¶
Index ¶
- Variables
- func CurrentLogLevel() string
- func HCLogger() hclog.Logger
- func Indent(s string) string
- func IsDebugOrHigher() bool
- func LogOutput() io.Writer
- func NewCloudLogger() hclog.Logger
- func NewLogger(name string) hclog.Logger
- func NewProviderLogger(prefix string) hclog.Logger
- func PanicHandler()
- func PanicHandlerWithTraceFn() func()
- func PluginOutputMonitor(source string) io.Writer
- func PluginPanics() []string
- func RegisterSink(f *os.File)
Constants ¶
This section is empty.
Variables ¶
var ( // ValidLevels are the log level names that OpenTofu recognizes. ValidLevels = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"} )
Functions ¶
func CurrentLogLevel ¶
func CurrentLogLevel() string
CurrentLogLevel returns the current log level string based the environment vars
func Indent ¶
Indent adds two spaces to the beginning of each line of the given string, with the goal of making the log level filter understand it as a line continuation rather than possibly as new log lines.
func IsDebugOrHigher ¶
func IsDebugOrHigher() bool
IsDebugOrHigher returns whether or not the current log level is debug or trace
func NewCloudLogger ¶
func NewCloudLogger() hclog.Logger
NewCloudLogger returns a logger for the cloud plugin, possibly with a different log level from the global logger.
func NewLogger ¶
func NewLogger(name string) hclog.Logger
NewLogger returns a new logger based in the current global logger, with the given name appended.
func NewProviderLogger ¶
func NewProviderLogger(prefix string) hclog.Logger
NewProviderLogger returns a logger for the provider plugin, possibly with a different log level from the global logger.
func PanicHandler ¶
func PanicHandler()
PanicHandler is called to recover from an internal panic in OpenTofu, and augments the standard stack trace with a more user friendly error message. PanicHandler must be called as a defered function, and must be the first defer called at the start of a new goroutine.
func PanicHandlerWithTraceFn ¶
func PanicHandlerWithTraceFn() func()
PanicHandlerWithTraceFn returns a function similar to PanicHandler which is called to recover from an internal panic in OpenTofu, and augments the standard stack trace with a more complete stack trace. The calling stack trace is captured before returing the augmented panicHandler The returned panicHandler must be called as a defered function, and must be the first defer called at the start of a new goroutine.
Callers of this function should create the panicHandler before any tight looping as there may be a performance impact if called excessively.
This only is a partial solution to the problem of panics within deeply nested go-routines. It only works between the go-routine being called and the calling go-routine. If you have multiple nested go-rotuines, it will only preserve the calling stack and the called panic stack. Idealy we would be able to use context or a similar construct to build a more comprehensive panic handler, but this is a significant step in the right direction that will dramatically improve crash debugging
func PluginOutputMonitor ¶
PluginOutputMonitor creates an io.Writer that will warn about any writes in the default logger. This is used to catch unexpected output from plugins, notifying them about the problem as well as surfacing the lost data for context.
func PluginPanics ¶
func PluginPanics() []string
PluginPanics returns a series of provider panics that were collected during execution, and formatted for output.
func RegisterSink ¶
SetupTempLog adds a new log sink which writes all logs to the given file.
Types ¶
This section is empty.