REQUEST: Default label on log method

15 views
Skip to first unread message

Patrick Hogan

unread,
Mar 29, 2012, 12:11:56 AM3/29/12
to firephp-dev
I request that there be a default label option on the log method. The
labels chained method is a great way to make the logged variables easy
to read. It would be nice to allow a default label that is named
after the variable name to be output to the console.

Christoph Dorn

unread,
Mar 29, 2012, 11:09:51 AM3/29/12
to firep...@googlegroups.com

So something like the following?

$console = FirePHP::to("page")->console();
$var = "Hello";
$console->label($console::LABEL_VAR_NAME)->log($var);

Which would print:

"$var: Hello"

Christoph

Patrick Hogan

unread,
Mar 29, 2012, 12:37:40 PM3/29/12
to firep...@googlegroups.com
Yes, in concept.  The only thing I could not think through last night is where would be the best place to set this value be.  If you set it on a per line basis in the label method, then you are violating DRY principles by potentially retyping below throughout your code.  In my opinion, this is just as bad as having to set a label each time.  If you have to write this line out, then why not just type in a custom label.  

$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)
$console->label($console::LABEL_VAR_NAME)

I was thinking that you could set it after the instantiation of the object.  

$console = FirePHP::to("page")->console();
$console->setLabelDefault($console::LABEL_VAR_NAME);

//any log calls after the default is set that are called without a chained label method will set a label according to the setLabelDefault value

$console->log($var)

//however if a log call after the default is set is called with a chained label method, then the chained label method will override the setLabelDefault value

$console->label('I trump the setLabelDefault value')->log($var)




--
You received this message because you are subscribed to the Google Groups "firephp-dev" group.
To post to this group, send email to firep...@googlegroups.com.
To unsubscribe from this group, send email to firephp-dev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/firephp-dev?hl=en.


Christoph Dorn

unread,
Mar 29, 2012, 12:47:34 PM3/29/12
to firep...@googlegroups.com
Defaults can be set now for everything using the chainable API:

$pageConsole = FirePHP::to("page")->console();

$autoLabelConsole = $pageConsole ->label($console::LABEL_VAR_NAME);
$pageConsole->log($var); -> label: NONE
$autoLabelConsole->log($var); -> label: $var
$autoLabelConsole->label('foo')->log($var); -> label: foo
$autoLabelConsole->log($var); -> label: $var
$pageConsole->log($var); -> label: NONE

So we just need the `$console::LABEL_VAR_NAME ` feature.

Makes sense?

Christoph

Patrick Hogan

unread,
Mar 29, 2012, 1:15:25 PM3/29/12
to firep...@googlegroups.com
Completely understand.  Yes, that feature would be very much appreciated.  

Reply all
Reply to author
Forward
0 new messages