Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Use NSLog when printing on the device#10

Closed
mwise wants to merge 3 commits into
OTGApps:masterfrom
mwise:nslog-on-device
Closed

Use NSLog when printing on the device#10
mwise wants to merge 3 commits into
OTGApps:masterfrom
mwise:nslog-on-device

Conversation

@mwise

@mwise mwise commented Jan 24, 2015

Copy link
Copy Markdown

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
Copy Markdown
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

mwise commented Jan 24, 2015

Copy link
Copy Markdown
Author

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

@jamonholmgren

Copy link
Copy Markdown
Contributor

👍

@andrewhavens

Copy link
Copy Markdown

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

@mwise

mwise commented Jan 15, 2016

Copy link
Copy Markdown
Author

@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

hgani commented Mar 22, 2016

Copy link
Copy Markdown

@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

mwise commented Mar 22, 2016

Copy link
Copy Markdown
Author

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants