{"record":{"id":"1d098092265031c1","repo":"hashicorp/nomad","slug":"eventlogger-is-not-supported-on-this-platform","errorCode":null,"errorMessage":"EventLogger is not supported on this platform","messagePattern":"EventLogger is not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/winsvc/event_logger_nonwindows.go","lineNumber":16,"sourceCode":"// Copyright IBM Corp. 2015, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\n//go:build !windows\n\npackage winsvc\n\nimport (\n\t\"errors\"\n\t\"io\"\n)\n\n// NewEventLogger is a stub for non-Windows platforms to generate\n// and error when used.\nfunc NewEventLogger(_ string) (io.WriteCloser, error) {\n\treturn nil, errors.New(\"EventLogger is not supported on this platform\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/winsvc/event_logger_nonwindows.go#L1-L18","documentation":"NewEventLogger on non-Windows platforms is a stub that always returns this error, because the Windows Event Log is only available on Windows. It exists so the API compiles cross-platform but fails fast if actually used elsewhere.","triggerScenarios":"Calling helper/winsvc.NewEventLogger(name) on Linux/macOS (any GOOS != windows); SetupLoggers invoking it on a non-Windows build.","commonSituations":"Portable code paths that unconditionally create an event logger regardless of OS; running a Windows-oriented service wrapper on Unix during development.","solutions":["Only call NewEventLogger on Windows (runtime.GOOS == \"windows\" build tag or runtime check)","On non-Windows platforms use the standard log writer instead of an EventLogger","If you see this unexpectedly, verify which binary/GOOS is actually running","Route logger setup through a platform abstraction that picks the right implementation"],"exampleFix":"// before\nw, err := winsvc.NewEventLogger(\"MyService\")\n// after\nvar w io.WriteCloser\nif runtime.GOOS == \"windows\" {\n  w, err = winsvc.NewEventLogger(\"MyService\")\n} else {\n  w = os.Stdout // or another non-Windows writer\n  err = nil\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"windows\" {\n  // do not call NewEventLogger; use standard writer\n}","typeGuard":null,"tryCatchPattern":"w, err := winsvc.NewEventLogger(\"MyService\")\nif err != nil {\n  log.Printf(\"event logger unavailable (%v); falling back to stdout\", err)\n  w = os.Stdout\n}","preventionTips":["Build-tag or runtime.GOOS-gate all winsvc calls","Use a platform abstraction for service logging","Never assume EventLogger exists outside Windows binaries","Test non-Windows builds before shipping portable code"],"tags":["go","windows","platform","logging"],"backgroundTag":"unsupported-platform-call","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}