Skip to content
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

logger: implement logger option #31

Merged
merged 1 commit into from
Apr 10, 2020
Merged

logger: implement logger option #31

merged 1 commit into from
Apr 10, 2020

Conversation

lopezator
Copy link
Owner

Add a Logger interface, along with a LoggerFunc and a new WithLogger option.

This would enable:

  • Customizing migrator output
  • Integrating a 3rd party logging tool

By default, migrator will work as before, just outputting to stdout.

Closes #6

@codecov
Copy link

codecov bot commented Apr 9, 2020

Codecov Report

Merging #31 into master will decrease coverage by 3.68%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #31      +/-   ##
==========================================
- Coverage   77.41%   73.73%   -3.69%     
==========================================
  Files           1        1              
  Lines          93       99       +6     
==========================================
+ Hits           72       73       +1     
- Misses         13       18       +5     
  Partials        8        8              
Impacted Files Coverage Δ
migrator.go 73.73% <66.66%> (-3.69%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update beba8dc...38a88a3. Read the comment docs.

@lopezator
Copy link
Owner Author

Would this be enough for you @adamdecaf?

You could use WithLogger option along with LoggerFunc function, and then do nothing inside to avoid printing.

migrator, err := New(Migrations(migrations...), WithLogger(LoggerFunc(func(string, ...interface{}) {
    // Doing nothing here would disable the output
})))

CC/ @dufcrule @glerchundi

Copy link

@adamdecaf adamdecaf left a comment

Choose a reason for hiding this comment

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

This would work great for me, thanks for the quick change!

@adamdecaf
Copy link

It also works to reformat logs into JSON, thanks!

@lopezator
Copy link
Owner Author

That's great! Did you used some 3rd party tool for json formatting?

@adamdecaf
Copy link

We use the go-kit/kit logger which has a JSON outputter.

@lopezator lopezator force-pushed the feature/logger branch 2 times, most recently from 2884ffb to 88a8df6 Compare April 9, 2020 19:17
@lopezator
Copy link
Owner Author

That's great. Thank you for testing it out!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@dufcrule
Copy link
Contributor

Just some minor changes to the README texts. Apart from that LGTM!

@lopezator
Copy link
Owner Author

Thank you for the review @dufcrule !!

Add a Logger interface, along with a LoggerFunc and a new WithLogger option.

This would enable:

- Customizing migrator output
- Integrating a 3rd party logging tool

By default, migrator will work as before, just outputting to stdout.

Closes #6
@lopezator lopezator merged commit bee4efd into master Apr 10, 2020
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.

3 participants