Log::Message::Structured::Component::AttributesFilter
package MyLogEvent; use Moose; use namespace::autoclean; with ('Log::Message::Structured', 'Log::Message::Structured::Stringify::AsJSON', 'Log::Message::Structured::Component::AttributesFilter' => { filter => 'out', name => qr /^foo/, }); has [qw/ foo bar /] => ( is => 'ro', required => 1 ); ... elsewhere ... use aliased 'My::Log::Event'; $logger->log(Event->new( foo => "ONE MILLION", bar => "ONE BILLION" )); # Logs: {"__CLASS__":"MyLogEvent","foo":"ONE MILLION"} # note that bar is not included in the structure
Augments the as_string method provided by Log::Message::Structured as a parameterised Moose role.
as_string
Enum : in, out. Specifies if the other criterias are to be used to filter in or out. Defaults to 'in'.
Enum : public, private. Filters on the attribute type
a RegexpRef or a CodeRef. Used to filter on the attribute name. The CodeRef will recieve the attribute's name in $_
a RegexpRef or a CodeRef. Used to filter on the attribute value. The CodeRef will recieve the attribute's value in $_
a CodeRef. Used to do custom filtering. Will recieve the Class::MOP::Attribute as first argument, and $self as second argument.
$self
Damien Krotkine (dams) <dams@cpan.org>.
<dams@cpan.org>
Licensed under the same terms as perl itself.
To install Log::Message::Structured, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Message::Structured
CPAN shell
perl -MCPAN -e shell install Log::Message::Structured
For more information on module installation, please visit the detailed CPAN module installation guide.