Skip to content

Commit

Permalink
[Fixed] Print subproject paths when logging
Browse files Browse the repository at this point in the history
When running the LicenseFinder with the `--recursive` option the output
becomes unclear as to which subproject is currently being processed.
By adding in the subproject path to the logging, it becomes slightly
easier to tell what is going on when running on large monorepos.
  • Loading branch information
swarren12 committed Aug 18, 2023
1 parent 46ae9f6 commit add2f96
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/license_finder/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def prepare_projects
clear_logs
package_managers = @scanner.active_package_managers
package_managers.each do |manager|
logger.debug manager.class, 'Running prepare on project'
logger.debug manager.class, "Running prepare on project '#{config.project_path}'"
manager.prepare
logger.debug manager.class, 'Finished prepare on project', color: :green
logger.debug manager.class, "Finished prepare on project '#{config.project_path}'", color: :green
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/license_finder/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def active_package_managers
active = pm_class.new(@config).active?

if active
@logger.info pm_class, 'is active', color: :green
@logger.info pm_class, "is active for '#{@project_path}'", color: :green
active_pm_classes << pm_class
else
@logger.debug pm_class, 'is not active', color: :red
@logger.debug pm_class, "is not active for '#{@project_path}'", color: :red
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/license_finder/scanner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module LicenseFinder
context 'when package manager is NOT installed' do
it 'should log all active packages' do
allow(bundler).to receive(:command_exists?).and_return false
expect(logger).to receive(:info).with(Bundler, 'is active', color: :green)
expect(logger).to receive(:info).with(Bundler, 'is active for \'\'', color: :green)
expect(logger).to receive(:info).with(Bundler, 'is not installed', color: :red)
expect(subject.active_packages).to_not be_nil
end
Expand All @@ -47,15 +47,15 @@ module LicenseFinder
it 'should log active states of package managers' do
bundler = double(:bundler, active?: true)
allow(Bundler).to receive(:new).and_return bundler
expect(logger).to receive(:info).with(Bundler, 'is active', color: :green)
expect(logger).to receive(:info).with(Bundler, 'is active for \'\'', color: :green)

subject.active_package_managers
end

it 'should log inactive states of package managers' do
bundler = double(:bundler, active?: false)
allow(Bundler).to receive(:new).and_return bundler
expect(logger).to receive(:debug).with(Bundler, 'is not active', color: :red)
expect(logger).to receive(:debug).with(Bundler, 'is not active for \'\'', color: :red)

subject.active_package_managers
end
Expand Down

0 comments on commit add2f96

Please sign in to comment.