feat: log out when a path is not matched to any formatter

Signed-off-by: Brian McGee <brian@bmcgee.ie>
This commit is contained in:
Brian McGee 2024-05-17 10:48:53 +01:00
parent 3c264c623e
commit c002eca8b7
No known key found for this signature in database
GPG Key ID: D49016E76AD1E8C0

View File

@ -57,12 +57,12 @@ func (f *Format) Run() (err error) {
} }
// create a prefixed logger // create a prefixed logger
l := log.WithPrefix("format") log.SetPrefix("format")
// ensure cache is closed on return // ensure cache is closed on return
defer func() { defer func() {
if err := cache.Close(); err != nil { if err := cache.Close(); err != nil {
l.Errorf("failed to close cache: %v", err) log.Errorf("failed to close cache: %v", err)
} }
}() }()
@ -87,7 +87,7 @@ func (f *Format) Run() (err error) {
formatterCfg := cfg.Formatters[name] formatterCfg := cfg.Formatters[name]
formatter, err := format.NewFormatter(name, Cli.TreeRoot, formatterCfg, globalExcludes) formatter, err := format.NewFormatter(name, Cli.TreeRoot, formatterCfg, globalExcludes)
if errors.Is(err, format.ErrCommandNotFound) && Cli.AllowMissingFormatter { if errors.Is(err, format.ErrCommandNotFound) && Cli.AllowMissingFormatter {
l.Debugf("formatter not found: %v", name) log.Debugf("formatter not found: %v", name)
continue continue
} else if err != nil { } else if err != nil {
return fmt.Errorf("%w: failed to initialise formatter: %v", err, name) return fmt.Errorf("%w: failed to initialise formatter: %v", err, name)
@ -383,6 +383,7 @@ func applyFormatters(ctx context.Context) func() error {
if matched { if matched {
stats.Add(stats.Matched, 1) stats.Add(stats.Matched, 1)
} else { } else {
log.Debugf("no match found: %s", file.Path)
// no match, so we send it direct to the processed channel // no match, so we send it direct to the processed channel
processedCh <- file processedCh <- file
} }