Aion-Format
view release on metacpan or search on metacpan
```
## accesslog ($format, @params)
ÐиÑÐµÑ Ð² STDOUT иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
```perl
trappout { accesslog "#{green}ACCESS#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[32mACCESS\e\[0m 6\n
```
## errorlog ($format, @params)
ÐиÑÐµÑ Ð² **STDERR** иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
```perl
trapperr { errorlog "#{red}ERROR#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[31mERROR\e\[0m 6\n
```
## p ($target; %properties)
`p` из Data::Printer Ñ Ð¿ÑедÑÑÑановленнÑми наÑÑÑойками.
ÐмеÑÑо неÑдобного пеÑвого паÑамеÑÑа иÑполÑзÑеÑÑÑ Ð¿ÑоÑÑо ÑкалÑÑ.
ÐеобÑзаÑелÑнÑй паÑамеÑÑ `%properties` позволÑÐµÑ Ð¿ÐµÑекÑÑваÑÑ Ð½Ð°ÑÑÑойки.
См. Ñакже `IO::Capture::Stderr`.
## trappout (&block)
ÐовÑÑка Ð´Ð»Ñ **STDOUT**.
Ð ÑлÑÑае оÑибки в блоке **STDOUT** воÑÑÑанавливаеÑÑÑ, а вÑвод в блоке â ÑеÑÑеÑÑÑ.
```perl
trappout { print "Stars: â¨" } # => Stars: â¨
trappout { print "Stars: â¨"; die "error" } # @=> error
```
См. Ñакже `IO::Capture::Stdout`.
## TiB ()
ÐонÑÑанÑа Ñавна Ð¾Ð´Ð½Ð¾Ð¼Ñ ÑебибайÑÑ.
```perl
TiB # -> 2**40
i18n/Aion/Format.ru-en.po view on Meta::CPAN
msgid "ÐовÑÑка Ð´Ð»Ñ **STDERR**."
msgstr "Trap for **STDERR**."
msgid "См. Ñакже `IO::Capture::Stderr`."
msgstr "See also `IO::Capture::Stderr`."
msgid "ÐовÑÑка Ð´Ð»Ñ **STDOUT**."
msgstr "Trap for **STDOUT**."
msgid "Ð ÑлÑÑае оÑибки в блоке `STDOUT` воÑÑÑанавливаеÑÑÑ, а вÑвод в блоке â ÑеÑÑеÑÑÑ."
msgstr "If there is an error in the block, `STDOUT` is restored, but the output in the block is lost."
msgid "См. Ñакже `IO::Capture::Stdout`."
msgstr "See also `IO::Capture::Stdout`."
msgid "ÐонÑÑанÑа Ñавна Ð¾Ð´Ð½Ð¾Ð¼Ñ ÑебибайÑÑ."
msgstr "The constant is equal to one tebibyte."
msgid "ÐонÑÑанÑа Ñавна Ð¾Ð´Ð½Ð¾Ð¼Ñ Ð³Ð¸Ð±Ð¸Ð±Ð°Ð¹ÑÑ."
msgstr "The constant is equal to one gibibyte."
lib/Aion/Format.md view on Meta::CPAN
```
## accesslog ($format, @params)
ÐиÑÐµÑ Ð² STDOUT иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
```perl
trappout { accesslog "#{green}ACCESS#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[32mACCESS\e\[0m 6\n
```
## errorlog ($format, @params)
ÐиÑÐµÑ Ð² **STDERR** иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
```perl
trapperr { errorlog "#{red}ERROR#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[31mERROR\e\[0m 6\n
```
## p ($target; %properties)
`p` из Data::Printer Ñ Ð¿ÑедÑÑÑановленнÑми наÑÑÑойками.
ÐмеÑÑо неÑдобного пеÑвого паÑамеÑÑа иÑполÑзÑеÑÑÑ Ð¿ÑоÑÑо ÑкалÑÑ.
ÐеобÑзаÑелÑнÑй паÑамеÑÑ `%properties` позволÑÐµÑ Ð¿ÐµÑекÑÑваÑÑ Ð½Ð°ÑÑÑойки.
lib/Aion/Format.md view on Meta::CPAN
См. Ñакже `IO::Capture::Stderr`.
## trappout (&block)
ÐовÑÑка Ð´Ð»Ñ **STDOUT**.
Ð ÑлÑÑае оÑибки в блоке **STDOUT** воÑÑÑанавливаеÑÑÑ, а вÑвод в блоке â ÑеÑÑеÑÑÑ.
```perl
trappout { print "Stars: â¨" } # => Stars: â¨
trappout { print "Stars: â¨"; die "error" } # @=> error
```
См. Ñакже `IO::Capture::Stdout`.
## TiB ()
ÐонÑÑанÑа Ñавна Ð¾Ð´Ð½Ð¾Ð¼Ñ ÑебибайÑÑ.
```perl
TiB # -> 2**40
lib/Aion/Format.pm view on Meta::CPAN
sub warncolor(@) {
print STDERR coloring @_
}
# ÐÐ»Ñ ÐºÑона: ÐиÑÐµÑ Ð² STDOUT
sub accesslog(@) {
print "[", POSIX::strftime("%F %T", localtime), "] ", coloring @_;
}
# ÐÐ»Ñ ÐºÑона: ÐиÑÐµÑ Ð² STDIN
sub errorlog(@) {
print STDERR "[", POSIX::strftime("%F %T", localtime), "] ", coloring @_;
}
#@category ÐÑеобÑазованиÑ
# ÐÑÐ¾Ð²Ð¾Ð´Ð¸Ñ ÑооÑвеÑÑÑвиÑ
#
# replace "...", qr/.../ => sub {...}, ...
#
lib/Aion/Format.pm view on Meta::CPAN
Like C<coloring>, but prints the formatted string to C<STDERR>.
trapperr { warncolor "#{green}ACCESS#r %i\n", 6 } # => \e[32mACCESS\e[0m 6\n
=head2 accesslog ($format, @params)
Writes to STDOUT using the C<coloring> function for formatting and adds a date-time prefix.
trappout { accesslog "#{green}ACCESS#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[32mACCESS\e\[0m 6\n
=head2 errorlog ($format, @params)
Writes to B<STDERR> using the C<coloring> function for formatting and adds a date-time prefix.
trapperr { errorlog "#{red}ERROR#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[31mERROR\e\[0m 6\n
=head2 p ($target; %properties)
C<p> from Data::Printer with preset settings.
Instead of the inconvenient first parameter, a simple scalar is used.
The optional C<%properties> parameter allows you to override settings.
trapperr { p +{cat => 123} } # ~> cat.+123
lib/Aion/Format.pm view on Meta::CPAN
=head2 transliterate ($s)
Transliterates Russian text.
transliterate "ÐÐ¸Ñ Ð²Ð¾ вÑÑм ÐиÑе!" # => Mir vo vsjom Mire!
=head2 trapperr (&block)
Trap for B<STDERR>.
If there is an error in the block, C<STDOUT> is restored, but the output in the block is lost.
trapperr { print STDERR "Stars: â¨" } # => Stars: â¨
See also C<IO::Capture::Stderr>.
=head2 trappout (&block)
Trap for B<STDOUT>.
If there is an error in the block, C<STDOUT> is restored, but the output in the block is lost.
trappout { print "Stars: â¨" } # => Stars: â¨
trappout { print "Stars: â¨"; die "error" } # @=> error
See also C<IO::Capture::Stdout>.
=head2 TiB ()
The constant is equal to one tebibyte.
TiB # -> 2**40
=head2 GiB ()
t/aion/format.t view on Meta::CPAN
#
# ## accesslog ($format, @params)
#
# ÐиÑÐµÑ Ð² STDOUT иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
#
::done_testing; }; subtest 'accesslog ($format, @params)' => sub {
::like scalar do {trappout { accesslog "#{green}ACCESS#r %i\n", 6 }}, qr{\[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[32mACCESS\e\[0m 6\n}, 'trappout { accesslog "#{green}ACCESS#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[32mACCESS\e\[0m ...
#
# ## errorlog ($format, @params)
#
# ÐиÑÐµÑ Ð² **STDERR** иÑполÑзÑÑ Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑÑнкÑÐ¸Ñ `coloring` и добавлÑÐµÑ Ð¿ÑеÑÐ¸ÐºÑ Ñ Ð´Ð°Ñой-вÑеменем.
#
::done_testing; }; subtest 'errorlog ($format, @params)' => sub {
::like scalar do {trapperr { errorlog "#{red}ERROR#r %i\n", 6 }}, qr{\[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[31mERROR\e\[0m 6\n}, 'trapperr { errorlog "#{red}ERROR#r %i\n", 6 } # ~> \[\d{4}-\d{2}-\d{2} \d\d:\d\d:\d\d\] \e\[31mERROR\e\[0m 6\n'; unde...
#
# ## p ($target; %properties)
#
# `p` из Data::Printer Ñ Ð¿ÑедÑÑÑановленнÑми наÑÑÑойками.
#
# ÐмеÑÑо неÑдобного пеÑвого паÑамеÑÑа иÑполÑзÑеÑÑÑ Ð¿ÑоÑÑо ÑкалÑÑ.
#
# ÐеобÑзаÑелÑнÑй паÑамеÑÑ `%properties` позволÑÐµÑ Ð¿ÐµÑекÑÑваÑÑ Ð½Ð°ÑÑÑойки.
#
t/aion/format.t view on Meta::CPAN
# См. Ñакже `IO::Capture::Stderr`.
#
# ## trappout (&block)
#
# ÐовÑÑка Ð´Ð»Ñ **STDOUT**.
#
# Ð ÑлÑÑае оÑибки в блоке `STDOUT` воÑÑÑанавливаеÑÑÑ, а вÑвод в блоке â ÑеÑÑеÑÑÑ.
#
::done_testing; }; subtest 'trappout (&block)' => sub {
local ($::_g0 = do {trappout { print "Stars: â¨" }}, $::_e0 = "Stars: â¨"); ::ok $::_g0 eq $::_e0, 'trappout { print "Stars: â¨" } # => Stars: â¨' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
eval {trappout { print "Stars: â¨"; die "error" }}; local ($::_g0 = $@, $::_e0 = "error"); ok defined($::_g0) && $::_g0 =~ /^${\quotemeta $::_e0}/, 'trappout { print "Stars: â¨"; die "error" } # @=> error' or ::diag ::_string_diff($::_g0, $::_e0, ...
#
# См. Ñакже `IO::Capture::Stdout`.
#
# ## TiB ()
#
# ÐонÑÑанÑа Ñавна Ð¾Ð´Ð½Ð¾Ð¼Ñ ÑебибайÑÑ.
#
::done_testing; }; subtest 'TiB ()' => sub {
local ($::_g0 = do {TiB}, $::_e0 = do {2**40}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'TiB # -> 2**40' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
( run in 0.628 second using v1.01-cache-2.11-cpan-39bf76dae61 )