Skip to content

Add centralized logging to the RubyGit gem#22

Merged
jcouball merged 1 commit intomainfrom
add_logging
Oct 16, 2020
Merged

Add centralized logging to the RubyGit gem#22
jcouball merged 1 commit intomainfrom
add_logging

Conversation

@jcouball
Copy link
Member

Description

As a user of the RubyGit gem
I want to be able to see what git commands are executed as I use the RubyGit gem
So that I can debug my use of the RubyGit gem

Add a centralized logger as an attribute to the RubyGit module.

Using the logger:

RubyGit.logger.debug('Debug message')

Setting the logger to capture log messages in an instance of StringIO:

require 'logger'
require 'stringio'
log_device = StringIO.new
RubyGit.logger = Logger.new(log_device, level: Logger::DEBUG)
RubyGit.logger.debug('Debug message')
log_device.string.include?('Debug message')
 => true

By default, RubyGit.logger should be an instance of NullLogger.

What is changed?

ruby_git.gemspec

  • Add runtime dependency on 'null-logger'

lib/ruby_git.rb and lib/ruby_git_spec.rb

  • Add the module attribute logger which defaults to an instance of NullLogger.
  • Change how RubyGit.git is documented so it shows up as a "Class Attribute" in the yard documentation to match how RubyGit.logger is documented.

lib/ruby_git/worktree.rb and lib/ruby_git/worktree_spec_initialize

  • Log creation of Worktree instances at debug level.

What else was changed and why?

  • Nothing

@jcouball jcouball requested a review from a team as a code owner October 16, 2020 17:46
Copy link

@frankthrock frankthrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jcouball jcouball merged commit a55042d into main Oct 16, 2020
@jcouball jcouball deleted the add_logging branch October 19, 2020 16:42
@jcouball jcouball mentioned this pull request Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants