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

Use NSLog when printing on the device #10

Closed
wants to merge 3 commits into from

Conversation

mwise
Copy link

@mwise mwise commented Jan 24, 2015

This PR updates Kernel#mp() to use NSLog when running on the device as discussed in #6

It basically just splits on newlines the output that would have been printed using puts on the simulator and prints each line using NSLog. I was skeptical this would work initially, but it seems to work pretty well in my limited testing.

I took the guts of MotionPrint.simulator? directly from BubbleWrap::Device, and it should be cached as a class instance variable and thus be pretty lightweight to call in repeated calls to Kernel#mp(). I added a spec for MotionPrint.simulator? that passes on both the simulator and the device. However, I have no idea how to test the actual NSLog part. I didn't want to add a mocking/stubbing library, and I'm pretty sure NSLog would be a hard thing to stub/spy on, regardless. Suggestions welcome on that front.

Anyway, please take a look and let me know if this is something worth pursuing.

Cheers,

Mark

@markrickert
Copy link
Member

Thanks for this!

Would would you think about adding a class method to MotionPrint that would enable this functionality? I'd prefer for my logs on device not to get cluttered when in production (since i leave all my mp statements in the code).

Something like:

def   def application(application, didFinishLaunchingWithOptions:launchOptions)
  #...
  MotionPrint.enable_nslog
  #...
end

and then only print to NSLog if enabled?

@mwise
Copy link
Author

mwise commented Jan 24, 2015

Ok, I added the opt-in stuff and took a stab at updating the README.

@jamonholmgren
Copy link
Contributor

👍

@andrewhavens
Copy link

@mwise Looks like there are merge conflicts in your branch. Do you mind fixing those?

@mwise
Copy link
Author

mwise commented Jan 15, 2016

@andrewhavens wow talk about a blast from the past! I'm not using RubyMotion these days and have limited time to look at this. I'll take a look as soon as I can - if a) my RubyMotion setup still works and b) the conflicts are easily resolved, then I'd be happy to update this PR. If it's being difficult, I may have to punt on it, since it's not something that I need right now.

@hgani
Copy link

hgani commented Mar 22, 2016

@andrewhavens

I created a pull request based on the original pull request from @mwise

#17

This one is based on the latest master so there shouldn't be any conflicts. Please review and merge.

Thanks guys

@mwise
Copy link
Author

mwise commented Mar 22, 2016

@hgani thanks for doing that. As it turns out, my RubyMotion environment is completely hosed, and not likely to come alive again anytime soon. Good luck!

@mwise mwise closed this Jul 19, 2018
@mwise mwise deleted the nslog-on-device branch July 19, 2018 13:48
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.

5 participants