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:
- TFM_LOG environment variable (TRACE|DEBUG|INFO|WARN|ERROR|OFF|JSON)
- --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 ¶
const ( EnvLog = "TFM_LOG" EnvLogPath = "TFM_LOG_PATH" )
Environment variable names, following the TF_LOG convention.
Variables ¶
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).
Types ¶
This section is empty.