func()

in machine.go [615:649]


func (m *Machine) setupLogging(ctx context.Context) error {
	path := m.Cfg.LogPath
	if len(m.Cfg.LogFifo) > 0 {
		path = m.Cfg.LogFifo
	}

	if len(path) == 0 {
		// No logging configured
		m.logger.Printf("VMM logging disabled.")
		return nil
	}

	// m.Cfg.LogLevel cannot be nil, but Firecracker allows setting a logger
	// without its level. Converting "" to nil to support the corner case.
	level := String(m.Cfg.LogLevel)
	if StringValue(level) == "" {
		level = nil
	}

	l := models.Logger{
		LogPath:       String(path),
		Level:         level,
		ShowLevel:     Bool(true),
		ShowLogOrigin: Bool(false),
	}

	_, err := m.client.PutLogger(ctx, &l)
	if err != nil {
		return err
	}

	m.logger.Debugf("Configured VMM logging to %s", path)

	return nil
}