{"record":{"id":"96dc194a064c1022","repo":"sirupsen/logrus","slug":"cannot-create-handler-from-nil-logger","errorCode":null,"errorMessage":"cannot create handler from nil logger","messagePattern":"cannot create handler from nil logger","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hooks/slog/handler.go","lineNumber":58,"sourceCode":"\n\t// fields holds attributes from prior WithAttrs calls, already resolved\n\t// under the group prefix that applied when they were added.\n\tfields logrus.Fields\n\n\t// groups is the current group name stack for attributes added later.\n\tgroups []string\n}\n\nvar _ slog.Handler = (*Handler)(nil)\n\n// NewHandler creates a [slog.Handler] that writes to the provided\n// [logrus.Logger].\n//\n// The provided logger must not be nil. NewHandler panics if logger is nil.\n// If opts is nil, the default options are used.\nfunc NewHandler(logger *logrus.Logger, opts *HandlerOptions) *Handler {\n\tif logger == nil {\n\t\tpanic(\"cannot create handler from nil logger\")\n\t}\n\tif opts == nil {\n\t\topts = &HandlerOptions{}\n\t}\n\treturn &Handler{\n\t\tlogger: logger,\n\t\topts:   *opts,\n\t}\n}\n\n// toLogrusLevel maps a slog level using LevelMapper or the default mapping.\nfunc (h *Handler) toLogrusLevel(level slog.Level) logrus.Level {\n\tif h.opts.LevelMapper != nil {\n\t\treturn h.opts.LevelMapper(level)\n\t}\n\treturn SlogLevel(level).Level()\n}\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/sirupsen/logrus/blob/457e372460c7a80ca7c800b51ebeee5362aaa180/hooks/slog/handler.go#L40-L76","documentation":"Error \"cannot create handler from nil logger\" thrown in sirupsen/logrus.","triggerScenarios":"Thrown at hooks/slog/handler.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"457e372460c7a80ca7c800b51ebeee5362aaa180","analyzedAt":"2026-08-16T02:52:47.002Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}