Subject: | Application control of log level prefix in LogText widget |
Hi there, firstly I love this widget, and expect to make good use of it!
Right now the log() operation will issue a mandatory "level prefix" in the text widget (refer to the "info" and "debug" lines below):
info
2017/03/24 14:44:21 INFO dispatchtk2.pl hello
debug
2017/03/24 14:44:21 DEBUG dispatchtk2.pl hello
It would be my preference to be able to control the display of the prefix, such that it would be able to display the following:
2017/03/24 14:43:36 INFO dispatchtk2.pl hello
2017/03/24 14:43:36 DEBUG dispatchtk2.pl hello
The code fragment is as follows:
sub log
{
my ($dw,%params) = @_;
$dw->insert('end',"$params{level}\n",
[$params{level}, 'label' ]);
$dw->insert('end',"$params{message}\n",
[$params{level}, 'message' ]);
}
Can I suggest that you add a conditional statement to allow the prefix to be avoided, e.g.
if ($params{show_prefix}) {
$dw->insert('end',"$params{level}\n",
[$params{level}, 'label' ]);
}
And have the show_prefix attribute default to 1 to preserve existing behavior.
In that way, I could override show_prefix to 0 following widget creation, and thus avoid the mandatory prefix.
Hope to hear from you soon!