logging objects

Ask, and ye shall receive.
randomstuff
Posts: 9
Joined: 15:03, 03 Mar 2015

logging objects

Postby randomstuff » 15:06, 03 Mar 2015

would it be possible to provide a more useful hyper.log in means of being able to logging objects?
if you try to hyper.log a whole object it just says [object Object], which isn't very useful

browser consoles usually have an ability to expand the object and see through its properties.

or would it be possible to use external console, such as google chrome console?

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: logging objects

Postby Fredrik » 10:48, 04 Mar 2015

[object Object] is the Javascript default conversion of Object to String. As far as I know, it cannot be changed.

However, we have a function evothings.printObject that may do what you want.

randomstuff
Posts: 9
Joined: 15:03, 03 Mar 2015

Re: logging objects

Postby randomstuff » 13:54, 05 Mar 2015

i know this is a default javascript string representation of object, that's why i asked whether would it be possible to print it in a more intelligent way, such as chrome or firefox does in the console.

by the way, evothings.printObject doesn't work :(

Code: Select all

LOG: [ERR] TypeError: undefined is not a function (evaluating 'evothings.printObject(distances)') [app.js: 130]


or should i copy paste the function definition from the evothings.js?

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: logging objects

Postby Fredrik » 14:17, 05 Mar 2015

You can either include evothings.js, like so, or copy/paste the function.

randomstuff
Posts: 9
Joined: 15:03, 03 Mar 2015

Re: logging objects

Postby randomstuff » 11:36, 06 Mar 2015

nope, it gives the error even with this included


<script src="libs/evothings/evothings.js"></script>

.. undefined is not a function (evaluating 'evothings.printObject ..

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: logging objects

Postby Fredrik » 12:10, 06 Mar 2015

Do you have the directories "libs/evothings" in your project folder? If not, the file "evothings.js" won't be there, the WebView will get a 404 when trying to load it, and will silently disregard the <script> tag.

randomstuff
Posts: 9
Joined: 15:03, 03 Mar 2015

Re: logging objects

Postby randomstuff » 09:56, 11 Mar 2015

yes, i have both :/

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: logging objects

Postby Fredrik » 11:50, 11 Mar 2015

Then I'm out of ideas. You'd better copy/paste the function.


Return to “Questions and answers”

Who is online

Users browsing this forum: Google [Bot] and 45 guests