{"record":{"id":"c3978f14a6e9f136","repo":"caddyserver/caddy","slug":"more-than-1-module-passed-in","errorCode":null,"errorMessage":"more than 1 module passed in","messagePattern":"more than 1 module passed in","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"context.go","lineNumber":575,"sourceCode":"// recent module associated with the context. Callers should not\n// pass in any arguments unless they want to associate with a\n// different module; it panics if more than 1 value is passed in.\n//\n// Originally, this method's signature was `Logger(mod Module)`,\n// requiring that an instance of a Caddy module be passed in.\n// However, that is no longer necessary, as the closest module\n// most recently associated with the context will be automatically\n// assumed. To prevent a sudden breaking change, this method's\n// signature has been changed to be variadic, but we may remove\n// the parameter altogether in the future. Callers should not\n// pass in any argument. If there is valid need to specify a\n// different module, please open an issue to discuss.\n//\n// PARTIALLY DEPRECATED: The Logger(module) form is deprecated and\n// may be removed in the future. Do not pass in any arguments.\nfunc (ctx Context) Logger(module ...Module) *zap.Logger {\n\tif len(module) > 1 {\n\t\tpanic(\"more than 1 module passed in\")\n\t}\n\tif ctx.cfg == nil {\n\t\t// often the case in tests; just use a dev logger\n\t\tl, err := zap.NewDevelopment()\n\t\tif err != nil {\n\t\t\tpanic(\"config missing, unable to create dev logger: \" + err.Error())\n\t\t}\n\t\treturn l\n\t}\n\tmod := ctx.Module()\n\tif len(module) > 0 {\n\t\tmod = module[0]\n\t}\n\tif mod == nil {\n\t\treturn Log()\n\t}\n\treturn ctx.cfg.Logging.Logger(mod)\n}","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/context.go#L557-L593","documentation":"Context.Logger is variadic only for backward compatibility; it accepts at most zero or one Module argument. Passing two or more modules is a caller bug (the extra arguments came from the deprecated Logger(module) form) and triggers an immediate panic.","triggerScenarios":"Calling ctx.Logger(modA, modB) — any call with len(module) > 1.","commonSituations":"Migrating old code that called Logger(mod) and accidentally splatting a slice: ctx.Logger(mods...); grep-and-replace introducing multiple arguments; IDE autocompletion adding extra params.","solutions":["Pass no argument: ctx.Logger() — the context's own module is used automatically","If you must override, pass exactly one module: ctx.Logger(mod)","Never splat a slice into Logger; select a single element first"],"exampleFix":"// before\nlogger := ctx.Logger(modA, modB)\n// after\nlogger := ctx.Logger()","handlingStrategy":"validation","validationCode":"if len(modules) > 1 {\n    return nil, fmt.Errorf(\"Logger accepts at most one module, got %d\", len(modules))\n}\nlogger := ctx.Logger(modules...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call ctx.Logger() with no arguments — the deprecated form needs none","Never splat slices into variadic Logger","Staticcheck can flag suspicious splats of deprecated params"],"tags":["caddy","go","logging","deprecated-api","panic"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}