UI-Various
view release on metacpan or search on metacpan
lib/UI/Various/core.pm view on Meta::CPAN
# errors can't use standard messaging here (like
# above we have a paradox; the statement is covered
# while the branch is not):
print "\n***** can't redirect STDERR: $! *****\n";
}
binmode(STDERR, ':utf8');
if ($UI->{stderr} == 2 and $new_value == 0)
{
print STDERR $UI->{messages};
}
$UI->{messages} = '';
$UI->{stderr} = $new_value;
}
}
}
return $UI->{stderr};
}
}
END {
stderr(0);
}
#########################################################################
=head2 B<using> - get currently used UI as text string
internal implementation of L<UI::Various::using|UI::Various/using - get
currently used UI>
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub using()
{
return $UI->{using};
}
#########################################################################
=head2 B<ui> - get currently used UI
$interface = UI::Various::core::ui();
=head3 example:
$_ = UI::Various::core::ui() . '::Main::_init';
{ no strict 'refs'; &$_($self); }
=head3 description:
This function returns the full name of the currently used user interface,
e.g. to access its methods.
=head3 returns:
full name of UI
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub ui(;$)
{
return $UI->{ui};
}
#########################################################################
=head2 B<fatal> - abort with error message
fatal($message_id, @message_data);
=head3 example:
fatal('bad_usage_of__1_as__2', __PACKAGE__, $pkg);
fatal('UI__Various__core_must_be_1st_used_from_UI__Various');
=head3 parameters:
$message_id ID of the text or format string in language module
@message_data optional additional text data for format string
=head3 description:
This function looks up the format (or simple) string passed in
C<$message_id> in the text hash of the currently used language, formats it
together with the C<@message_data> with sprintf and passes it on to
C<L<croak|Carp>>.
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub fatal($;@)
{
my $message_id = shift;
local $_ = sprintf(msg($message_id), @_); # using $_ to allow debugging
croak($_);
}
#########################################################################
=head2 B<error> / B<warning> / B<info> - print error / warning / info message
error($message_id, @message_data);
warning($message_id, @message_data);
info($message_id, @message_data);
=head3 example:
warning('message__1_missing_in__2', $message_id, $UI->{language});
=head3 parameters:
$message_id ID of the text or format string in language module
@message_data optional additional text data for format string
=head3 description:
If the current logging level is lower than C<ERROR> / C<WARNING> / C<INFO>
these functions do nothing. Otherwise they print the formatted message
using C<_message>.
( run in 0.610 second using v1.01-cache-2.11-cpan-524268b4103 )