logging

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logging provides the global structured logger for tfm.

The design mirrors hashicorp/terraform/internal/logging: a single go-hclog InterceptLogger is initialised once (via Init) and all packages obtain named child loggers via NewLogger.

Log level is controlled by:

  1. TFM_LOG environment variable (TRACE|DEBUG|INFO|WARN|ERROR|OFF|JSON)
  2. --verbose / -V CLI flag → effective level INFO

The environment variable takes precedence over the CLI flag. TFM_LOG_PATH, when set, redirects all log output to the named file.

Index

Constants

View Source
const (
	EnvLog     = "TFM_LOG"
	EnvLogPath = "TFM_LOG_PATH"
)

Environment variable names, following the TF_LOG convention.

Variables

View Source
var ValidLevels = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"}

ValidLevels lists the accepted values for TFM_LOG.

Functions

func CurrentLevel

func CurrentLevel() string

CurrentLevel returns the string representation of the active log level.

func Init

func Init(verboseFlag bool)

Init initialises the global logger from the environment and the --verbose flag value. It must be called once, early in cobra's initialisation chain (inside cobra.OnInitialize or initConfig), before any commands run.

Level precedence: TFM_LOG env var > verboseFlag > default (OFF).

func NewLogger

func NewLogger(name string) hclog.Logger

NewLogger returns a named child of the global logger. The name is appended to "tfm" (e.g. "tfm.copy.workspaces").

Types

This section is empty.

Jump to

Keyboard shortcuts

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