http://codereview.appspot.com/28059
Suggested spec changed from original proposal:
- Think it makes sense to model the API after the very popular Firebug/WebKit logging API. Instead of gadgets.log(msg, level), the proposed API is gadgets.log(msg), gadgets.warn(msg), and gadgets.error(msg), in addition to gadgets.setLogLevel(level)
- Added gadgets.log.NONE as a logging level, to suppress logging entirely.
http://codereview.appspot.com/28059
Suggested spec changed from original proposal:
- Think it makes sense to model the API after the very popular Firebug/WebKit logging API. Instead of gadgets.log(msg, level), the proposed API is gadgets.log(msg), gadgets.warn(msg), and gadgets.error(msg), in addition to gadgets.setLogLevel(level)
- Added gadgets.log.NONE as a logging level, to suppress logging entirely.
Other notes:
- console.log() in Firebug supports a list of arguments which are formatted as a string. However, this isn't supported in WebKit flavors, and I thought it best to leave out of the core API. Think this can be an implementation choice (to accept a list of parameters instead of the one message param)
- Considered that we could just create the Firebug/WebKit console object if it doesn't exist on a browser - the API would then have been console.log() (which would always work). However, it was pointed out to me that the setLogLevel() function is important - you really don't want random Firebug messages in production. I could even set the logLevel as a URL parameter in different implementations (&debugLevel=3)
- The API is a little strange with namespaces. We have console.log both as a function and console.log as a namespace. I think this is better in the end - the API calls need to be short to be effective (so no gadgets.log.log()), and gadgets.log felt like the right namespace (I tried "gadgets.logging" in an early draft, but it just didn't stick), but I thought it worth mentioning.
A big note is that gadgets.log() is very useful. I started using this in internal development projects, and I can't live without it. Having a log() statement that is always available, without needing additional includes, is very helpful.
Evan
I think this makes sense.
Please create a patch.
On Tue, Mar 17, 2009 at 8:13 PM, Evan Gilbert <uid...@google.com> wrote:http://codereview.appspot.com/28059
Suggested spec changed from original proposal:
- Think it makes sense to model the API after the very popular Firebug/WebKit logging API. Instead of gadgets.log(msg, level), the proposed API is gadgets.log(msg), gadgets.warn(msg), and gadgets.error(msg), in addition to gadgets.setLogLevel(level)
- Added gadgets.log.NONE as a logging level, to suppress logging entirely.
Other notes:
- console.log() in Firebug supports a list of arguments which are formatted as a string. However, this isn't supported in WebKit flavors, and I thought it best to leave out of the core API. Think this can be an implementation choice (to accept a list of parameters instead of the one message param)
We would want to be careful about this, as developers expecting multiple arguments to be logged on a system that didn't implement this would likely have most of their important logging information dropped (I typically use something like console.log("functionName", arg1, arg2); ). I think we can just safely say that only one argument will be supported.
On Mon, Mar 30, 2009 at 11:52 AM, Arne Roomann-Kurrik <kur...@google.com> wrote:On Tue, Mar 17, 2009 at 8:13 PM, Evan Gilbert <uid...@google.com> wrote:http://codereview.appspot.com/28059
Suggested spec changed from original proposal:
- Think it makes sense to model the API after the very popular Firebug/WebKit logging API. Instead of gadgets.log(msg, level), the proposed API is gadgets.log(msg), gadgets.warn(msg), and gadgets.error(msg), in addition to gadgets.setLogLevel(level)
- Added gadgets.log.NONE as a logging level, to suppress logging entirely.
Other notes:
- console.log() in Firebug supports a list of arguments which are formatted as a string. However, this isn't supported in WebKit flavors, and I thought it best to leave out of the core API. Think this can be an implementation choice (to accept a list of parameters instead of the one message param)
We would want to be careful about this, as developers expecting multiple arguments to be logged on a system that didn't implement this would likely have most of their important logging information dropped (I typically use something like console.log("functionName", arg1, arg2); ). I think we can just safely say that only one argument will be supported.Agreed that the official API will be one argument. However I don't see harm in implementations doing pass thru - this is very useful if you do most of your testing on a single browser and know what you're doing.
I think if we spec the behavior of logging such that this is true WRT behavior:
gadgets.log(someValue) == gadgets.log(gadgets.json.stringify(someValue))
then the array mechanism is trivial to spec and implement.
From:
opensocial-an...@googlegroups.com
[mailto:opensocial-an...@googlegroups.com] On Behalf Of Kevin
Marks
Sent: Tuesday, March 31, 2009 1:50 AM
To: opensocial-an...@googlegroups.com
Subject: [opensocial-and-gadgets-spec] Re: gadgets.log prototype
On Tue, Mar 31, 2009 at 12:54 AM, Evan Gilbert <uid...@google.com> wrote:
I think if we spec the behavior of logging such that this is true WRT behavior:
gadgets.log(someValue) == gadgets.log(gadgets.json.stringify(someValue))
Can you post the patch? Thinking through things at the spec level will bring clarity sooner.
Instead of specifying how we work with parameters, let’s log the arguments array so that we support 1, 2, or more parameters with no issues. Would that be acceptable?
Instead of specifying how we work with parameters, let’s log the arguments array so that we support 1, 2, or more parameters with no issues. Would that be acceptable?
Sounds fine—just digging in a bit.
Given the current construction, I’m confident we can be more expressive as we learn more.
Go fer it