Log::A...eHandle(3pm)

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

πŸ’– Log::Any::Adapter::FileHandle πŸ’–

okay so bestie, we're in the User Contributed Perl Documentation corner of the manual pages, and this lil icon is called Log::Any::Adapter::FileHandle. The manual page header just labels it Log::A...eHandle(3pm) because terminals are dramatic and truncate things, but you and me? We know her full name. 🫢


✨ NAME ✨

Log::Any::Adapter::FileHandle β€” it's a basic Log::Any::Adapter whose whole entire job is forwarding your messages to a filehandle. that's it. that's the gig. πŸ’…


🌸 VERSION 🌸

version 0.010 β€” yes she's on 0.010, she's vintage, she's established, respect her. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

the vibe, in code form:

use Log::Any qw($log);
use Log::Any::Adapter;

# Send all logs to Log::Any::Adapter::FileHandle
Log::Any::Adapter->set('FileHandle');

$log->info("Hello world");

literally three lines of setup and your logs are out the door. no cap. πŸ”₯


πŸŽ€ DESCRIPTION πŸŽ€

so this module is a basic adapter that will simply forward log messages to a filehandle, or honestly to any object that supports a print method β€” think IO::String, IO::Socket::INET, Plack's $env->{psgi.errors} object, that whole squad. it's giving flexible. it's giving "bring your own sink". ✨

the author made it so their scripts running under damontools or runit could output messages to locally defined logs. and here's the tea: it does not timestamp messages β€” that responsibility is delegated to the external log capture mechanism. so don't come for her about timestamps, that was never her job. 😌

you can override the default configuration by passing extra arguments to the Log::Any set_adapter method:

πŸ’œ the options πŸ’œ

  • fh β€” pass in your IO::Handle-like object right here bestie. if this isn't specified, it will default to opening STDERR. and if the object supports an autoflush method, autoflush will be enabled β€” unless no_autoflush is set. read that again, it's a little conditional and it matters. 🌈
  • no_autoflush β€” disables automatically turning on autoflush on the fh object. that's the whole thing. short queen. πŸŽ€
  • format β€” a sprintf string that controls the formatting of the message. it is supplied 2 arguments: the log level as supplied by Log::Any (usually all-lowercase), and the message to be logged. the default is:
"[%s] %s\n"
⚠️ heads up: this value should contain the log record terminator, such as a newline. don't skip the newline and then act surprised, i'm begging. 😭
  • escape β€” one of 'none' (the default), 'newline', or 'nonascii'. it controls how messages are pre-filtered before passing them to a filehandle. this is handy if you want to smoosh messages into a single line (for easier filtering + processing), or if you want to filter non ascii characters for safe terminal printing. two very different little gremlin use cases, both valid. 🧚

Copyright 2014 by Jason Jay Rodrigues <jasonjayr+oss@gmail.com> πŸ’Œ

Log::Any::Adapter::FileHandle is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose. like, she's doing her best, okay? πŸ™ˆ

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay. πŸ’–


and that's the whole page bestie β€” this was perl v5.36.0, dated 2022-11-19, filed under Log::A...eHandle(3pm) in the User Contributed Perl Documentation. go forth and forward your logs, you absolute main character. 🌟🫢

πŸ“¦ where this page comes from