Skip to content

Conversation

@ttaylorr
Copy link
Contributor

This pull request allows callers of the git/githistory.NewRewriter() function to pass in a git/githistory/log.(*Logger) that they created, instead of just supplying the io.Writer sink.

This allows callers to maintain a handle on the given logger without expanding the API of functions that *HistoryRewriter receives. Callers that hold a reference to the logger can add their own arbitrary tasks to it, while maintaining the same synchronicity guarentees that the *Logger type provides.

This is done in anticipation of the git-lfs-migrate(1) command being able to fetch remote refs before beginning a migration. Doing so will require the migrator to log that it is fetching so it does not appear to hang, and thus requires a change like the one presented in this pull request.


/cc @git-lfs/core

Copy link
Contributor

@technoweenie technoweenie left a comment

Choose a reason for hiding this comment

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

Agreed. I don't think accepting only an io.Writer makes sense when the rewriter is just calling log.NewLogger().

@ttaylorr ttaylorr merged commit 4383de1 into master Aug 30, 2017
@ttaylorr ttaylorr deleted the migrate-logger-pass-in branch August 30, 2017 16:45
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request May 26, 2023
In commit 3129b9a of PR git-lfs#2537 the
"githistory" package was updated so the WithLogger global option
variable now required a *log.Logger argument instead of calling
log.NewLogger().  This was done so the "git lfs migrate" commands
could pass in a previously initialized logger to which the commands
had already written log messages; that change was introduced in
PR git-lfs#2538.

In the same commit of PR git-lfs#2537, a WithLoggerTo global option function
was added to preserve the existing behaviour.  However, this option
has never been utilized, and so to reduce unnecessary complexity
we just remove it now.

Note that the use of functional options in the Git LFS project
stems from PR git-lfs#2295 and is inspired by the design proposed in several
articles from 2014; see, for reference:

https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants