drop support for windows event log

This commit is contained in:
Jonas Leder 2024-08-03 23:58:03 +02:00
commit 906d69bcd3
2 changed files with 1 additions and 14 deletions

View file

@ -8,20 +8,14 @@ import (
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
"github.com/rifflock/lfshook"
"github.com/sirupsen/logrus"
"golang.org/x/sys/windows/svc/eventlog"
)
var Log *logrus.Logger
var evtlog *eventlog.Log
func Init() {
Log = logrus.New()
elog, err := eventlog.Open("Cloud-Init")
if err != nil {
panic(err)
}
e, err := os.Executable()
e, _ := os.Executable()
lastBackslashIndex := strings.LastIndex(e, "\\")
workdir := e[:lastBackslashIndex]
path := workdir + "/cloud-init.log"
@ -46,10 +40,5 @@ func Init() {
},
&logrus.TextFormatter{},
))
evtlog = elog
Log.SetLevel(logrus.DebugLevel)
}
func Close() {
evtlog.Close()
}

View file

@ -96,7 +96,6 @@ func application() {
if rebootRequired {
log.Log.Warn("Reboot is required to apply the changes")
if len(os.Args) > 1 && os.Args[1] == "firstboot" {
log.Close()
os.Exit(1) // Exit 1 means, reboot the system and then continue https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-deployment-runsynchronous-runsynchronouscommand-willreboot
} else if config.Configuration.RebootIfRequired {
windows.Reboot()
@ -104,7 +103,6 @@ func application() {
}
log.Log.Info("Done executing Cloud-Init")
log.Close()
os.Exit(0)
}