mirror of
https://github.com/kairos-io/immucore.git
synced 2025-06-01 11:15:59 +00:00
This makes immucore run more in parallel rather than block everything else. We just tell sysroot.mount that eventually it will be mounted and to wait for a bit. This allows us to be more flexible where to run and run in parallel in cases like cdrom in which we may do things but we need the sysroot to be mounted already but not from us. Also adds the initramfs stage directly in immucore and merges all the dracut config into one Dont create sysroot, just add a timeout override so it waits for us Dont block on the service, just make sure to finish before initrd.target Fix mounts from cmdline More proper log Store logs under the /run/immucore dir Store rootfs and initramfs logs separated Do not log the full stages in INFO level Run initramfs stage in immucore directly on boot and cd/netboot Drop systemd requirement from dracut module Signed-off-by: Itxaka itxaka.garcia@spectrocloud.com
41 lines
926 B
Go
41 lines
926 B
Go
package utils
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/kairos-io/immucore/internal/constants"
|
|
"github.com/rs/zerolog"
|
|
)
|
|
|
|
var Log zerolog.Logger
|
|
var logFile *os.File
|
|
|
|
func CloseLogFiles() {
|
|
logFile.Close()
|
|
}
|
|
|
|
func SetLogger() {
|
|
var loggers []io.Writer
|
|
_ = os.MkdirAll(constants.LogDir, os.ModeDir|os.ModePerm)
|
|
logFile, err := os.Create(filepath.Join(constants.LogDir, "immucore.log"))
|
|
if err == nil {
|
|
loggers = append(loggers, zerolog.ConsoleWriter{Out: logFile})
|
|
}
|
|
|
|
loggers = append(loggers, zerolog.ConsoleWriter{Out: os.Stderr})
|
|
|
|
multi := zerolog.MultiLevelWriter(loggers...)
|
|
Log = zerolog.New(multi).With().Logger()
|
|
Log.WithLevel(zerolog.InfoLevel)
|
|
|
|
// Set debug logger
|
|
debug := len(ReadCMDLineArg("rd.immucore.debug")) > 0
|
|
debugFromEnv := os.Getenv("IMMUCORE_DEBUG") != ""
|
|
if debug || debugFromEnv {
|
|
Log = zerolog.New(multi).With().Caller().Logger()
|
|
Log.WithLevel(zerolog.DebugLevel)
|
|
}
|
|
}
|