-
-
Notifications
You must be signed in to change notification settings - Fork 676
feat: remove logger from taskfile package #2082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -117,7 +115,6 @@ func Exists(l *logger.Logger, path string) (string, error) { | |||
for _, taskfile := range defaultTaskfiles { | |||
alt := filepathext.SmartJoin(path, taskfile) | |||
if _, err := os.Stat(alt); err == nil { | |||
l.VerboseOutf(logger.Magenta, "task: [%s] Not found - Using alternative (%s)\n", path, taskfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m OK with removing it because, even though we could use it for troubleshooting, I don’t think it’s used at all. I just wanted to make sure it wasn’t an oversight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, its difficult to log here without passing a function in. If we really want the logs, we could compare the input/output in the caller and log there instead, but I decided it wasn't worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Our package API should not rely on our internal
logger
package. Logging is a CLI-specific responsibility and users that want to use Task as a package may want to implement their own logging. As such, this PR removes the logger from thetaskfile
package entirely.Normally this would mean we lose the ability to insert debug logs into our code. However, we can pass a generic function into the
Reader
which will process logs instead. This allows all of Task's current logging to remain in place while a 3rd party user can either omit the logging function when creating their reader (and discard the logs) or implement their own custom logging.I have also done the same thing for the prompt function so that package API users can implement their own prompt functionality.
Finally, the reader now uses functional options in its constructor. This allows us to set sensible defaults instead of the caller having to specify everything each time (including the new logging functions).