-
Notifications
You must be signed in to change notification settings - Fork 355
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
New IOIOCoreLib #103
New IOIOCoreLib #103
Conversation
back to their static blocks and added a simple System.out.println() to IOIOConnectionRegistry for loggin :/
interface by loading a platform-specific concrete class (using Class.forname()) to public log field. Actual registration-instantiation happens inside static{} blocks of IOIOAndroidApplicationHelper and IOIOPcApplicationHelper
Hey Ytai thanks for your suggestions they really helped me. Check out my last 4 commits:
|
Hey Thanos, Let's start with a single commit refactoring the log. After that, following up with an additional commit for breaking the libraries would be straightforward, and that can be followed by your introduction of the AS projects, which is our ultimate goal. Breaking up this pull-request into those logical pieces would make the review process more efficient and would result in a much cleaner history. I believe this change can be made with no impact at all on the call sites.
This removes the compile-time dependency of the As a side-note: Thanks for bearing with me! |
Hey, I've been trying to figure out what exactly you want to achive with this but I am a little confused here. I have no clue where you want me to declare that private Can you please take a look at my Take a look at the whole Logger class and especially at My whole point from the beginning was to use that syntax: |
If you rename your Logger class to ioio.lib.spi.Log and implement all the On Sat, Feb 7, 2015 at 5:25 PM, Thanos Fisherman notifications@github.com
|
Ah I see what you mean with "no call site changes". So you want instead of Logger.log.i() to just do Log.i() just like the normal android Log API while keeping this platform agnostic at the same time. As for the addLogBootstrap it is initialized inside the static blocks of IOIOAndroidApplicationHelper and IOIOPcApplicationHelper. Isn't that ok? P.S. I think we have 8 hours difference or something so it may take me a while to see your posts |
Doing the initialization in a static block is a better interface since it
|
hey Ytai check out my refactored Log class. I made the static d,e,i....etc methods that forward to the corespondings methods of private log_ interface. Now the call sites have been renamed back to as they used to be (using Log.i instead of Logger.log.i) I believe it's ok now. I didn't do any change on addLogBootstrap method tho cause I still don't get it. Check this. I initialize the private log_ interface using the following code inside IOIOAndroidApplicationHelper static {
Log.addLogBootstrap("ioio.lib.util.android.ConcreteLog");
IOIOConnectionRegistry
.addBootstraps(new String[] {
"ioio.lib.impl.SocketIOIOConnectionBootstrap",
"ioio.lib.android.accessory.AccessoryConnectionBootstrap",
"ioio.lib.android.bluetooth.BluetoothIOIOConnectionBootstrap",
"ioio.lib.android.device.DeviceConnectionBootstrap"});
} and inside IOIOPcApplicationHelper static {
Log.addLogBootstrap("ioio.lib.util.pc.ConcreteLog");
IOIOConnectionRegistry
.addBootstraps(new String[] { "ioio.lib.pc.SerialPortIOIOConnectionBootstrap" });
} I believe the Log is initialized early enough. Could it be earlier? |
You're getting close: if you now simply move the log_ initialization into the Log class as a static block and use a unified class name (e.g. ioio.lib.SPI.ConcreteLog), there is no longer any impact on client code. |
Oh, and please get rid of the log level filtering. |
So you want me to make a new package ioio.lib.SPI in both IOIOPcApplicationHelper and IOIOAndroidApplicationHelper and move each of their ConcreteLog classes in there? |
It is not new. This package (ioio.lib.spi) has always existed in the On Sun, Feb 8, 2015 at 5:21 PM, Thanos Psaridis notifications@github.com
|
Ah you are right it's there! I just deleted it cause I didn't need it anymore :P I Could never thought we would follow that kind of implementation (which may seem very natural in practise but it took me a while to figure it out how to do it) |
ok cool I'm renaming the ConcreteLog into LogImpl too |
Awesome. Please just make a pull request containing one commit with only
|
A single commit with everything I've done so far? Or just the Log class? |
Just the Log. Let's get it merged and then we can follow up with the next
|
ok here you go ^^^ |
Btw If you eventually merge my last commit you'd better delete those auto generated //TODO comments cause android studio inspection usually complains about that stuff (among other as well) |
Thanos, if you look at the current state of this pull request, it has 10 commits and 132 changed files. |
Well I've never used that rebase thing before. I'm using egit from within 2015-02-10 4:47 GMT+02:00 Ytai Ben-Tsvi notifications@github.com:
|
IOIO Android apps are just normal Android apps, so you can do from them
|
I guess this answer was not intended for me here :P Check out my previous reply tho (I've never used rebase and pull requests before so I don't know what to do now) 👍 |
Neat! Good Idea how you shrunk the ILogger interface into 1 method keeping everything minimally invasive :D Now if you still want to move all the common code to a separate project (IOIOLibCore) that's up to you. I'd want to have it as a separate project tho cause it is easier to deal with in android studio and maybe make it a .jar file and push it to maven or something. (no need for .aar files in common code) I still don't know how the maven procedure is done, but I'm willing to help as far as my knowledge allows |
I'm still debating myself about the usefulness of breaking the libraries
The last two points might be somewhat mitigated by AS/Maven, but I'm not On Fri, Feb 13, 2015 at 8:37 AM, Thanos Psaridis notifications@github.com
|
Good points.
Hopefully maven-gradle intergration will work with eclipse and ADT too in 2015-02-14 1:40 GMT+02:00 Ytai Ben-Tsvi notifications@github.com:
|
Sorry, it's hopeless outdated. Please feel free to reopen it again |
Actually it was about time to close this. The content of this pull request has been already implemented so no need to do anything here. :) |
Hey Ytai I hope I made this pull request correctly. Let me explain briefly what I did.
I just took all the common IOIO code and moved it to this seperate library called IOIOCoreLib.
Then I made a static Logger.log class inside the core that implements a "strategy-like" pattern so that when it's called from desktop it will print on console using println() and when it's called from android it will print on logcat using log().
Now in order to do that I had to move the static blocks from IOIOAndroidApplicationHelper to its constructor. Otherwise i would get NPE cause static block tries to log before my Logger is instantiated. But then I saw this caused some issues probably related to threading stuff im not sure So I then moved the code back to static block and added a simple system.out.println to IOIOConnectionRegistry. Now my unified logger works fine. But if you definatelly want those log messages inside IOIOConnectionRegistry to be printed as a verbose on logcat, we will have to find another way (I have something in my mind)