Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remote Logging and Object Inspection #46

Merged
merged 11 commits into from

5 participants

Wen-Hao Lue Ryan Olson Jake Marsh Mike Lewis Francis Chong
Wen-Hao Lue
Collaborator

EDIT: README done!

This pull request adds remote logging via PDLog() and PDLogObjects() functions. It outputs the results into the Console tab of DevTools. This is the precursor to getting a functional REPL working for PonyDebugger.

PDLog() works like NSLog(). PDLogObjects() takes NSObjects and outputs them with full inspection capability. So doing PDLogObjects(@"This is the app:", [UIApplication sharedApplication]) would show the full text, and the introspectable application singleton.

Things that I did in this pull request:

  • Updated PDTwitterTest, since Twitter deprecated their public timeline endpoint. The test app only uses search functionality. However, this is going to be deprecated at some point, so we'll have to find an alternative eventually.

  • Added PDConsoleDomainController to handle console output.

  • Removed PDArrayContainer/PDDictionaryContainer, and replaced it with implementations using categories. It simplified the code that creates PDRuntimeRemoteObjects, though it does make NSSet slower since order is never stored anywhere.

Mike Lewis mikelikespie was assigned
wlue added some commits
Wen-Hao Lue wlue Basic PDLog functionality. Need to fix up interface, and add more var…
…iables.
724c2c8
Wen-Hao Lue wlue Re-organizing classes/categories.
Making PDLog/PDLogObjects. Re-working property descriptor calculation, fixing Twitter Test app.
27521b9
Wen-Hao Lue
Collaborator

README done!

Ryan Olson ryanolsonk commented on the diff
ObjC/PonyDebugger/NSObject+PDRuntimePropertyDescriptor.m
@@ -160,12 +187,21 @@ - (PDRuntimePropertyDescriptor *)PD_propertyDescriptorForSelector:(SEL)selector;
return descriptor;
}
-- (PDRuntimePropertyDescriptor *)PD_propertyDescriptorForProperty:(NSString *)propertyName;
+- (PDRuntimePropertyDescriptor *)PD_propertyDescriptorForPropertyName:(NSString *)propertyName property:(objc_property_t)property

What is the reason for adding the property argument here? I don't see it referenced in the method.

Wen-Hao Lue Collaborator
wlue added a note

I originally did that because valueForKey does not work for all types of data. In the future, when I have a bit more time to hack around with the runtime, the way to grab the actual data would be to use the reference of the property_t, which is computed where it's called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ObjC/PonyDebugger/NSObject+PDRuntimePropertyDescriptor.m
@@ -16,13 +16,93 @@
#import <PonyDebugger/PDRuntimeTypes.h>
#import <PonyDebugger/PDArrayContainer.h>
#import <PonyDebugger/PDDictionaryContainer.h>

PDDictionaryContainer and PDArrayContainer have been removed/renamed.

Wen-Hao Lue Collaborator
wlue added a note

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...nyDebugger/NSOrderedSet+PDRuntimePropertyDescriptor.h
((2 lines not shown))
+// NSOrderedSet+PDRuntimePropertyDescriptor.h
+// PonyDebugger
+//
+// Created by Wen-Hao Lue on 2013-02-03.
+//
+// Licensed to Square, Inc. under one or more contributor license agreements.
+// See the LICENSE file distributed with this work for the terms under
+// which Square, Inc. licenses this file to you.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSOrderedSet (PDRuntimePropertyDescriptor)
+
+- (id)PD_objectAtIndex:(NSUInteger)index;
+

Does this category need - (PDRuntimePropertyDescriptor *)PD_propertyDescriptorForPropertyObject:(NSObject *)property; like the others?

Wen-Hao Lue Collaborator
wlue added a note

It uses the superclass method, which is on NSSet, so it should be fine.

NSOrderedSet is (somewhat surprisingly) not a subclass of NSSet. It inherits directly from NSObject. http://nshipster.com/nsorderedset/

Wen-Hao Lue Collaborator
wlue added a note

Ah, I assumed wrong, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Ryan Olson ryanolsonk commented on the diff
ObjC/PonyDebugger/PDConsoleDomainController.m
((70 lines not shown))
+ }
+
+ [text deleteCharactersInRange:NSMakeRange(text.length - 1, 1)];
+
+ PDConsoleConsoleMessage *consoleMessage = [[PDConsoleConsoleMessage alloc] init];
+ consoleMessage.level = @"log";
+ consoleMessage.source = @"console-api";
+ consoleMessage.stackTrace = [[NSArray alloc] init];
+ consoleMessage.parameters = parameters;
+ consoleMessage.repeatCount = [NSNumber numberWithInteger:1];
+ consoleMessage.text = text;
+
+ [self.domain messageAddedWithMessage:consoleMessage];
+}
+
+- (void)clear;

Would it make sense to expose this in the header and add a public method on PDDebugger that calls through to it?

Wen-Hao Lue Collaborator
wlue added a note

Great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Ryan Olson ryanolsonk commented on the diff
ObjC/PonyDebugger/PDConsoleDomainController.m
((37 lines not shown))
+ });
+
+ return defaultInstance;
+}
+
++ (Class)domainClass;
+{
+ return [PDConsoleDomain class];
+}
+
+#pragma mark - PDConsoleCommandDelegate
+
+// Clears console messages collected in the browser.
+- (void)domain:(PDConsoleDomain *)domain clearMessagesWithCallback:(void (^)(id error))callback;
+{
+ callback(nil);

I'm wondering if the PDRuntimeDomainController could get rid of its objectReferences when the console is cleared. Seems unnecessary to keep them around.

Wen-Hao Lue Collaborator
wlue added a note

Right, probably could do that with a list that temporarily stores the references it's holding. Good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Ryan Olson

I checked out the branch and took a look through the code. Very cool stuff! It's awesome to see this project continue to move forward. I haven't had a chance to test it other than what's in the example app, but for the most part it looks pretty good to me.

Ryan Olson

It would also be cool to have something like an "inherited" pseudo property on all objects that have a superclass so that you could view any inherited properties. I tried just showing all the inherited properties alongside the properties of the instance's class but it gets too crowded. I think it's useful information though if the presentation was right.

Without inherited:
Screen Shot 2013-03-14 at 5 23 41 PM

With inherited:
Screen Shot 2013-03-14 at 5 19 22 PM

This was referenced
David Apgar davidapgar referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Jake Marsh

This seems wonderful, any idea when this might be merged into master?

Mike Lewis
Admin

LGTM btw

Wen-Hao Lue
Collaborator

@jakemarsh Working on it!

Francis Chong

very cool!

Wen-Hao Lue wlue merged commit 7c9f983 into from
Wen-Hao Lue wlue deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2013
  1. Wen-Hao Lue
  2. Wen-Hao Lue

    Re-organizing classes/categories.

    wlue authored
    Making PDLog/PDLogObjects. Re-working property descriptor calculation, fixing Twitter Test app.
Commits on Mar 10, 2013
  1. Wen-Hao Lue
  2. Wen-Hao Lue
Commits on Apr 28, 2013
  1. Wen-Hao Lue

    Severity.

    wlue authored
  2. Wen-Hao Lue

    Merge from upstream.

    wlue authored
  3. Wen-Hao Lue
  4. Wen-Hao Lue
  5. Wen-Hao Lue

    Update comments.

    wlue authored
  6. Wen-Hao Lue

    Typo

    wlue authored
  7. Wen-Hao Lue

    Clear remote objects properly.

    wlue authored
Something went wrong with that request. Please try again.