App::I...::Print(3pm)

πŸ“¦
version 0.57 Β· 2 versions
  • 0.57 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.57 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– App::I...::Print(3pm) β€” aka App::Info::Handler::Print πŸ’–

User Contributed Perl Documentation · bestie edition 🌸


✨ NAME ✨

App::Info::Handler::Print β€” it prints App::Info event messages. That's the whole job. It ate. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use App::Info::Category::FooApp;
use App::Info::Handler::Print;

my $stdout = App::Info::Handler::Print->new( fh => 'stdout' );
my $app = App::Info::Category::FooApp->new( on_info => $stdout );

# Or...
my $app = App::Info::Category::FooApp->new( on_error => 'stderr' );

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. App::Info::Handler::Print objects handle App::Info events by printing their messages to a filehandle. Which means β€” and this is the slay part β€” if you want event messages going to a file, or to a system filehandle, this class literally just does that for you. no cap.

but here's the tea β˜• β€” App::Info::Handler::Print is most effective for info and error events. the unknown and prompt events? those are better handled by event handlers that actually know how to prompt users for data. for an example of that whole situation, go look at App::Info::Handler::Prompt. it's giving ✨built different✨.

when it loads, App::Info::Handler::Print registers itself with App::Info::Handler, setting up a couple of strings that you can pass to an App::Info concrete subclass constructor. these strings are shortcuts that tell App::Info how to create the proper App::Info::Handler::Print object for handling events. the registered strings are, and I cannot stress this enough:

  • stdout β€” prints event messages to STDOUT. iconic behavior fr fr.
  • stderr β€” prints event messages to STDERR. also iconic, but angrier 🫢

and if you wanna know how to make App::Info::Handler::Print print event messages to a different filehandle? check the new() constructor below, bestie. πŸ‘‘


πŸ’… INTERFACE πŸ’…

🌸 Constructor 🌸

⭐ new

my $stderr_handler = App::Info::Handler::Print->new;
$stderr_handler = App::Info::Handler::Print->new( fh => 'stderr' );
my $stdout_handler = App::Info::Handler::Print->new( fh => 'stdout' );
my $fh = FileHandle->new($file);
my $fh_handler = App::Info::Handler::Print->new( fh => $fh );

constructs a new App::Info::Handler::Print and returns it. main character energy, truly. it can take a single parameterized argument, fh, which can be any one of these values:

  • stderr β€” constructs a App::Info::Handler::Print object that prints App::Info event messages to STDERR. dramatic? maybe. correct? yes. πŸ’€
  • stdout β€” constructs a App::Info::Handler::Print object that prints App::Info event messages to STDOUT. the classic. the blueprint. 🌈
  • FileHandle
  • GLOB β€” pass in a reference and App::Info::Handler::Print will assume that it's a filehandle reference that it can print to. heads up though, bestie: pass in something that can't be printed to and it will trigger an exception when App::Info::Handler::Print tries to print to it. 😭 that's not a vibe. read your refs carefully.
🚨 if the fh parameter is not passed, new() will default to creating an App::Info::Handler::Print object that prints App::Info event messages to STDOUT. it's defaulting, your honor. ✨

🧚 handler

this method is called by App::Info to print out the message from events. that's it. that's the method. short, sweet, does exactly what it says on the tin. πŸ’–


🫢 SUPPORT 🫢

this module is stored in an open GitHub repository β€” http://github.com/theory/app-info/ β€” feel free to fork and contribute! the audacity (affectionate) of open source, we love to see it. πŸŽ€

please file bug reports via GitHub Issues β€” http://github.com/theory/app-info/issues/ β€” or by sending mail to bug-App-Info@rt.cpan.org. don't be shy, the maintainers want to hear from you. πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

David E. Wheeler <david@justatheory.com> β€” the icon, the legend, the one who wrote it. πŸ’…


🌈 SEE ALSO 🌈

  • App::Info documents the event handling interface. start here, bestie, fr fr.
  • App::Info::Handler::Carp handles events by passing their messages to Carp module functions.
  • App::Info::Handler::Prompt offers event handling more appropriate for unknown and confirm events. (remember the tea from earlier? this is that. πŸ“)
  • App::Info::Handler describes how to implement custom App::Info event handlers. build your own, main character. ✨

Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, legally speaking. ⭐


and that's the whole page, bestie!! πŸŒΈπŸ¦‹πŸ’– written for perl v5.36.0, dated 2022-12-06. go forth and print those events. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from