{"record":{"id":"4adb75eaf174699e","repo":"hashicorp/terraform","slug":"logger-name-required","errorCode":null,"errorMessage":"logger name required","messagePattern":"logger name required","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/logging/logging.go","lineNumber":119,"sourceCode":"\t\t} else {\n\t\t\tlogOutput = f\n\t\t}\n\t}\n\n\treturn hclog.NewInterceptLogger(&hclog.LoggerOptions{\n\t\tName:              name,\n\t\tLevel:             logLevel,\n\t\tOutput:            logOutput,\n\t\tIndependentLevels: true,\n\t\tJSONFormat:        json,\n\t})\n}\n\n// NewLogger returns a new logger based in the current global logger, with the\n// given name appended.\nfunc NewLogger(name string) hclog.Logger {\n\tif name == \"\" {\n\t\tpanic(\"logger name required\")\n\t}\n\treturn &logPanicWrapper{\n\t\tLogger: logger.Named(name),\n\t}\n}\n\n// NewProviderLogger returns a logger for the provider plugin, possibly with a\n// different log level from the global logger.\nfunc NewProviderLogger(prefix string) hclog.Logger {\n\tl := &logPanicWrapper{\n\t\tLogger: logger.Named(prefix + \"provider\"),\n\t}\n\n\tlevel := providerLogLevel()\n\tlogger.Debug(\"created provider logger\", \"level\", level)\n\n\tl.SetLevel(level)\n\treturn l","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/logging/logging.go#L101-L137","documentation":"Panics in NewLogger (logging.go:119). It creates a named child logger and requires a non-empty name; an empty name panics by design to avoid ambiguous/anonymous loggers.","triggerScenarios":"Calling logging.NewLogger(\"\") (empty string) when creating a named logger.","commonSituations":"Internal Terraform code passing an empty prefix variable, or custom integrations calling NewLogger with an unset name argument.","solutions":["Pass a non-empty, descriptive name to NewLogger.","Guard the call site: if the name variable may be empty, supply a default before calling."],"exampleFix":"// before\nl := NewLogger(\"\")\n// after\nl := NewLogger(\"myprovider\")","handlingStrategy":"validation","validationCode":"func newLoggerSafe(name string) hclog.Logger {\n    if name == \"\" { name = \"default\" }\n    return logging.NewLogger(name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call NewLogger with an empty string.","Default the name variable at the call site."],"tags":["terraform","logging","precondition","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}