Skip to content

Commit

Permalink
move unnecessary logs from info to debug or error (#1781)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 authored Feb 11, 2025
1 parent 0dbf690 commit 1cecdee
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ func (b *Build) BuildPackage(ctx context.Context) error {
}

if b.EmptyWorkspace {
log.Infof("empty workspace requested")
log.Debugf("empty workspace requested")
} else {
// Prepare workspace directory
if err := os.MkdirAll(b.WorkspaceDir, 0o755); err != nil {
Expand Down Expand Up @@ -1120,17 +1120,17 @@ func getPathForPackageSBOM(sbomDirPath, pkgName, pkgVersion string) string {

func (b *Build) SummarizePaths(ctx context.Context) {
log := clog.FromContext(ctx)
log.Infof(" workspace dir: %s", b.WorkspaceDir)
log.Debugf(" workspace dir: %s", b.WorkspaceDir)

if b.GuestDir != "" {
log.Infof(" guest dir: %s", b.GuestDir)
log.Debugf(" guest dir: %s", b.GuestDir)
}
}

func (b *Build) summarize(ctx context.Context) {
log := clog.FromContext(ctx)
log.Infof("melange %s is building:", version.GetVersionInfo().GitVersion)
log.Infof(" configuration file: %s", b.ConfigFile)
log.Debugf(" configuration file: %s", b.ConfigFile)
b.SummarizePaths(ctx)
}

Expand Down Expand Up @@ -1161,7 +1161,7 @@ func (b *Build) buildWorkspaceConfig(ctx context.Context) *container.Config {
if fi, err := os.Stat(b.CacheDir); err == nil && fi.IsDir() {
mountSource, err := realpath.Realpath(b.CacheDir)
if err != nil {
log.Infof("could not resolve path for --cache-dir: %s", err)
log.Errorf("could not resolve path for --cache-dir: %s", err)
}

mounts = append(mounts, container.BindMount{Source: mountSource, Destination: container.DefaultCacheDir})
Expand Down
6 changes: 3 additions & 3 deletions pkg/build/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,17 @@ func (t *Test) TestPackage(ctx context.Context) error {

func (t *Test) SummarizePaths(ctx context.Context) {
log := clog.FromContext(ctx)
log.Infof(" workspace dir: %s", t.WorkspaceDir)
log.Debugf(" workspace dir: %s", t.WorkspaceDir)

if t.GuestDir != "" {
log.Infof(" guest dir: %s", t.GuestDir)
log.Debugf(" guest dir: %s", t.GuestDir)
}
}

func (t *Test) Summarize(ctx context.Context) {
log := clog.FromContext(ctx)
log.Infof("melange %s is testing:", version.GetVersionInfo().GitVersion)
log.Infof(" configuration file: %s", t.ConfigFile)
log.Debugf(" configuration file: %s", t.ConfigFile)
t.SummarizePaths(ctx)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func buildCmd() *cobra.Command {
// Git auto-detection should be "best effort" and not fail the build if it
// fails.
if configFileGitCommit == "" {
log.Infof("git commit for build config not provided, attempting to detect automatically")
log.Debugf("git commit for build config not provided, attempting to detect automatically")
commit, err := detectGitHead(ctx, buildConfigFilePath)
if err != nil {
log.Warnf("unable to detect commit for build config file: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func compile() *cobra.Command {
// Git auto-detection should be "best effort" and not fail the build if it
// fails.
if configFileGitCommit == "" {
log.Infof("git commit for build config not provided, attempting to detect automatically")
log.Debugf("git commit for build config not provided, attempting to detect automatically")
commit, err := detectGitHead(ctx, buildConfigFilePath)
if err != nil {
log.Warnf("unable to detect commit for build config file: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestCmd(ctx context.Context, archs []apko_types.Architecture, baseOpts ...b

errg.Go(func() error {
if err := bc.TestPackage(ctx); err != nil {
log.Infof("ERROR: failed to test package. the test environment has been preserved:")
log.Errorf("ERROR: failed to test package. the test environment has been preserved:")
bc.SummarizePaths(ctx)

return fmt.Errorf("failed to test package: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/container/docker/docker_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (dk *docker) TerminatePod(ctx context.Context, cfg *mcontainer.Config) erro
func (dk *docker) TestUsability(ctx context.Context) bool {
log := clog.FromContext(ctx)
if _, err := dk.cli.Ping(ctx); err != nil {
log.Infof("cannot use docker for containers: %v", err)
log.Errorf("cannot use docker for containers: %v", err)
return false
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/container/qemu_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ func (b qemuOCILoader) LoadImage(ctx context.Context, layer v1.Layer, arch apko_
// in case of some kernel images, we also need the /lib/modules directory to load
// necessary drivers, like 9p, virtio_net which are foundamental for the VM working.
if qemuModule, ok := os.LookupEnv("QEMU_KERNEL_MODULES"); ok {
clog.FromContext(ctx).Info("qemu: QEMU_KERNEL_MODULES env set, injecting modules in initramfs")
clog.FromContext(ctx).Debugf("qemu: QEMU_KERNEL_MODULES env set, injecting modules in initramfs")
if _, err := os.Stat(qemuModule); err == nil {
clog.FromContext(ctx).Infof("qemu: local QEMU_KERNEL_MODULES dir detected, injecting")
clog.FromContext(ctx).Debugf("qemu: local QEMU_KERNEL_MODULES dir detected, injecting")
layer, err = injectKernelModules(ctx, layer, qemuModule)
if err != nil {
clog.FromContext(ctx).Errorf("qemu: could not inject needed kernel modules into initramfs: %v", err)
Expand Down Expand Up @@ -422,7 +422,7 @@ func createMicroVM(ctx context.Context, cfg *Config) error {

// if no size is specified, let's go for a default
if cfg.Disk == "" {
clog.FromContext(ctx).Infof("qemu: no disk space specified, using default: %s", defaultDiskSize)
clog.FromContext(ctx).Debugf("qemu: no disk space specified, using default: %s", defaultDiskSize)
cfg.Disk = defaultDiskSize
}

Expand All @@ -442,7 +442,7 @@ func createMicroVM(ctx context.Context, cfg *Config) error {

// qemu-system-x86_64 or qemu-system-aarch64...
qemuCmd := exec.CommandContext(ctx, fmt.Sprintf("qemu-system-%s", cfg.Arch.ToAPK()), baseargs...)
clog.FromContext(ctx).Infof("qemu: executing - %s", strings.Join(qemuCmd.Args, " "))
clog.FromContext(ctx).Debugf("qemu: executing - %s", strings.Join(qemuCmd.Args, " "))

output, err := qemuCmd.CombinedOutput()
if err != nil {
Expand All @@ -465,7 +465,7 @@ func createMicroVM(ctx context.Context, cfg *Config) error {
try++
time.Sleep(time.Millisecond * 500)

clog.FromContext(ctx).Infof("qemu: waiting for ssh to come up, try %d of %d", try, retries)
clog.FromContext(ctx).Debugf("qemu: waiting for ssh to come up, try %d of %d", try, retries)
// Attempt to connect to the address
err = checkSSHServer(cfg.SSHAddress)
if err == nil {
Expand Down Expand Up @@ -625,7 +625,7 @@ func generateDiskFile(ctx context.Context, diskSize string) (string, error) {
// we need bytes
size = size * 1024

clog.FromContext(ctx).Infof("qemu: generating disk image, name %s, size %s:", diskName.Name(), diskSize)
clog.FromContext(ctx).Debugf("qemu: generating disk image, name %s, size %s:", diskName.Name(), diskSize)
return diskName.Name(), os.Truncate(diskName.Name(), size)
}

Expand Down Expand Up @@ -696,7 +696,7 @@ func getHostKey(ctx context.Context, cfg *Config) error {

// Write the host key to the known_hosts file
hostKeyLine := fmt.Sprintf("%s %s %s\n", cfg.SSHAddress, hostKey.Type(), base64.StdEncoding.EncodeToString(hostKey.Marshal()))
clog.FromContext(ctx).Infof("host-key: %s", hostKeyLine)
clog.FromContext(ctx).Debugf("host-key: %s", hostKeyLine)

knownHost, err := os.CreateTemp("", "known_hosts_*")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/convert/apkbuild/apkbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c Context) Generate(ctx context.Context, apkBuildURI, pkgName string) erro
err = c.buildFetchStep(ctx, apkConverter)
if err != nil {
// lets not error if we can't automatically add the fetch step
log.Infof("skipping fetch step for %s", err.Error())
log.Errorf("skipping fetch step for %s", err.Error())
}

// maps the APKBUILD values to convert config
Expand Down

0 comments on commit 1cecdee

Please sign in to comment.