Skip to content

Commit a23f606

Browse files
Refactor logging: Remove logging functionality across all packages to make room for the new UI components
1 parent 2633ecc commit a23f606

32 files changed

+6
-607
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ Intended to interactively fill missing metadata fields.
180180
- Current status: stubbed / not implemented.
181181
- Future work: implement user prompting and (optionally) model card fetching.
182182

183-
### `internal/logging`
184-
185-
Small opt-in logger used across internal packages (writes only when a writer is configured).
186-
187183
### `internal/ui`
188184

189185
Very small ANSI-color helper used for banners and colored log prefixes.

cmd/completeness.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/idlab-discover/AIBoMGen-cli/internal/completeness"
1111
bomio "github.com/idlab-discover/AIBoMGen-cli/internal/io"
12-
"github.com/idlab-discover/AIBoMGen-cli/internal/metadata"
1312
"github.com/idlab-discover/AIBoMGen-cli/internal/ui"
1413
)
1514

@@ -33,11 +32,7 @@ var completenessCmd = &cobra.Command{
3332

3433
// Wire internal package logging based on log level.
3534
if level != "quiet" {
36-
lw := cmd.ErrOrStderr()
37-
completeness.SetLogger(lw)
38-
if level == "debug" {
39-
metadata.SetLogger(lw)
40-
}
35+
// Logging removed
4136
}
4237

4338
// Get input path and format from viper

cmd/enrich.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/idlab-discover/AIBoMGen-cli/internal/completeness"
87
"github.com/idlab-discover/AIBoMGen-cli/internal/enricher"
9-
"github.com/idlab-discover/AIBoMGen-cli/internal/fetcher"
108
bomio "github.com/idlab-discover/AIBoMGen-cli/internal/io"
11-
"github.com/idlab-discover/AIBoMGen-cli/internal/metadata"
129
"github.com/spf13/cobra"
1310
"github.com/spf13/viper"
1411
)
@@ -47,13 +44,7 @@ from Hugging Face API and README before enrichment.`,
4744

4845
// Wire internal package logging
4946
if level != "quiet" {
50-
lw := cmd.ErrOrStderr()
51-
enricher.SetLogger(lw)
52-
completeness.SetLogger(lw)
53-
fetcher.SetLogger(lw)
54-
if level == "debug" {
55-
metadata.SetLogger(lw)
56-
}
47+
// Logging removed
5748
}
5849

5950
// Read existing BOM

cmd/generate.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ import (
1212
"github.com/spf13/cobra"
1313
"github.com/spf13/viper"
1414

15-
"github.com/idlab-discover/AIBoMGen-cli/internal/builder"
16-
"github.com/idlab-discover/AIBoMGen-cli/internal/fetcher"
1715
"github.com/idlab-discover/AIBoMGen-cli/internal/generator"
1816
bomio "github.com/idlab-discover/AIBoMGen-cli/internal/io"
19-
"github.com/idlab-discover/AIBoMGen-cli/internal/metadata"
2017
"github.com/idlab-discover/AIBoMGen-cli/internal/scanner"
2118
"github.com/idlab-discover/AIBoMGen-cli/internal/ui"
2219
)
@@ -131,12 +128,7 @@ func runGenerate(cmd *cobra.Command, args []string) error {
131128

132129
// Wire internal package logging for debug mode
133130
if level == "debug" {
134-
lw := cmd.ErrOrStderr()
135-
fetcher.SetLogger(lw)
136-
metadata.SetLogger(lw)
137-
builder.SetLogger(lw)
138-
scanner.SetLogger(lw)
139-
generator.SetLogger(lw)
131+
// Logging removed
140132
}
141133

142134
// Get HF settings

cmd/validate.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/idlab-discover/AIBoMGen-cli/internal/completeness"
87
bomio "github.com/idlab-discover/AIBoMGen-cli/internal/io"
9-
"github.com/idlab-discover/AIBoMGen-cli/internal/metadata"
108
"github.com/idlab-discover/AIBoMGen-cli/internal/ui"
119
"github.com/idlab-discover/AIBoMGen-cli/internal/validator"
1210
"github.com/spf13/cobra"
@@ -47,12 +45,7 @@ var validateCmd = &cobra.Command{
4745

4846
// Wire internal package logging based on log level.
4947
if level != "quiet" {
50-
lw := cmd.ErrOrStderr()
51-
validator.SetLogger(lw)
52-
if level == "debug" {
53-
metadata.SetLogger(lw)
54-
completeness.SetLogger(lw)
55-
}
48+
// Logging removed
5649
}
5750

5851
// Get format from viper

internal/builder/bom_builder.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func NewBOMBuilder(opts Options) *BOMBuilder {
1717
}
1818

1919
func (b BOMBuilder) Build(ctx BuildContext) (*cdx.BOM, error) {
20-
logf(ctx.ModelID, "build start")
2120

2221
comp := buildMetadataComponent(ctx)
2322

@@ -43,13 +42,11 @@ func (b BOMBuilder) Build(ctx BuildContext) (*cdx.BOM, error) {
4342
metadata.ApplyFromSources(spec, src, tgt)
4443
}
4544

46-
logf(ctx.ModelID, "build ok")
4745
return bom, nil
4846
}
4947

5048
// BuildDataset builds a dataset component into BOM.components
5149
func (b BOMBuilder) BuildDataset(ctx DatasetBuildContext) (*cdx.Component, error) {
52-
logf(ctx.DatasetID, "build dataset start")
5350

5451
comp := buildDatasetComponent(ctx)
5552

@@ -70,7 +67,6 @@ func (b BOMBuilder) BuildDataset(ctx DatasetBuildContext) (*cdx.Component, error
7067
metadata.ApplyDatasetFromSources(spec, src, tgt)
7168
}
7269

73-
logf(ctx.DatasetID, "build dataset ok")
7470
return comp, nil
7571
}
7672

internal/builder/bom_builder_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package builder
22

33
import (
4-
"io"
54
"strings"
65
"testing"
76

@@ -96,8 +95,6 @@ func TestBuildMetadataComponent_SetsTypeAndNonNilModelCard(t *testing.T) {
9695
// Test Build function creates BOM with metadata component
9796
func TestBOMBuilder_Build_CreatesBOMWithMetadataComponent(t *testing.T) {
9897
b := NewBOMBuilder(DefaultOptions())
99-
SetLogger(io.Discard)
100-
t.Cleanup(func() { SetLogger(nil) })
10198

10299
// Keep Scan.Name empty so registry won't override the name.
103100
ctx := BuildContext{

internal/builder/logging.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

internal/completeness/logging.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

internal/completeness/report.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,18 @@ func (r Report) ToUIReport() ui.CompletenessReport {
5959
// PrintReport writes the report to the configured logger writer.
6060
// If no logger writer is configured, it produces no output.
6161
func PrintReport(r Report) {
62-
logf("Model score=%.1f%% (%d/%d)", r.Score*100, r.Passed, r.Total)
6362

6463
if len(r.MissingRequired) > 0 {
65-
logf("missing required: %s", joinKeys(r.MissingRequired))
6664
}
6765
if len(r.MissingOptional) > 0 {
68-
logf("missing optional: %s", joinKeys(r.MissingOptional))
6966
}
7067

7168
// Print dataset reports if any
7269
if len(r.DatasetReports) > 0 {
73-
logf("")
74-
logf("Dataset Components:")
75-
for dsName, dsReport := range r.DatasetReports {
76-
logf(" %s: score=%.1f%% (%d/%d)", dsName, dsReport.Score*100, dsReport.Passed, dsReport.Total)
70+
for _, dsReport := range r.DatasetReports {
7771
if len(dsReport.MissingRequired) > 0 {
78-
logf(" missing required: %s", joinDatasetKeys(dsReport.MissingRequired))
7972
}
8073
if len(dsReport.MissingOptional) > 0 {
81-
logf(" missing optional: %s", joinDatasetKeys(dsReport.MissingOptional))
8274
}
8375
}
8476
}

0 commit comments

Comments
 (0)