- Notifications
You must be signed in to change notification settings - Fork 129
This is my attempt to fix issue #16 with Logging trait #18
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
Add support for Java 6
…-2.11.0-RC4 Upgrade to Scala 2.11.0 RC4
…-2.11.0 Upgrade to Scala 2.11.0 and SLF4J 1.7.7
Fix LoggerSupport visibility issues (closes lightbend-labs#12)
Backport macros to support Scala 2.10.x on master branch
| Hi @akorneev, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Typesafe Contributors License Agreement: |
| Ok, signed the CLA now. |
| @akorneev, thanks for your work, looks pretty good. Yet I think that instead of adding another abstraction, we should think about simplifying things: As there's only one implementation for the API module, namely the SLF4J based one, we could just drop the API module. What do you think? |
| Actually, this separation between API and implementation was the only reason we decided to upgrade from 1.x branch. First, even if we currently have no other implementations except SLF4J based one, it makes a code much cleaner, when abstractions depends only on another abstractions: trait This { requires: That with Logging => //... } //usage class ThisImpl extends This with ThatImpl with slf4j.LoggingSecond, it simplifies testing of logging code, because its much easier to mock Logging trait than than the SLF4J logger itself: class ThisSpec extends FunSpec with MockitoSugar { //this will be used to test logging code trait LoggingMock extends Logging { class MockedLogger extends Logger { override def adapter: LoggerAdapter = mock[LoggerAdapter] } override def logger: Logger = new MockedLogger } //it's methods will do nothing trait NoopLogging extends Logging { //... } describe("This"){ it("should log something") { val test = new This extends ThatMock with LoggingMock test.doSomething() verify(test.logger.adapter).error("something") } it("should not make much noise in console") { val test = new This extends ThatMock with NoopLogging test.doSomething() } } } |
| I don't buy your first argument, I rather consider the logging abstraction over engineered, at least given the current state. Wrt the second argument, do you really consider logging something worth mocking? |
| Sometimes, yes. But I agree that the ability to mock in itself is hardly worth the additional complexity. |
| Updated. |
| @akorneev, could you please describe the goal and design for the latest changes? |
| Sure. I implemented your suggestion to drop the API module. I removed the Logging trait and moved the rest of If someone wants to use The project now has two modules: |
| @akorneev, thank you! I don't think it's necessary for a library to have separate projects, that's only needed for the library using macros and user code. Could you please give it a try? What do others think about removing the API module? |
| @hseeberger, your are right, we actually do not need separate project for macros, removed it. And a small correction to my previous comment: I actually did not removed the |
| I have simplified Scala Logging substantially, e.g. only one module, one package, etc. Check out the new version 3.0.0. Hence this is no longer relevant, but nevertheless kudos for your contributions! |
…t-best-practice-deploy Update deploy.sbt.disabled
No description provided.