Files
perl-MooX-Log-Any/perl-MooX-Log-Any.spec
2025-08-12 18:15:51 +02:00

93 lines
2.6 KiB
RPMSpec

#
# spec file for package perl-MooX-Log-Any
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define cpan_name MooX-Log-Any
Name: perl-MooX-Log-Any
Version: 0.4.4
Release: 0
# 0.004004 -> normalize -> 0.4.4
%define cpan_version 0.004004
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Role to add Log::Any
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/C/CA/CAZADOR/%{cpan_name}-%{cpan_version}.tar.gz
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Log::Any)
BuildRequires: perl(Log::Any::Test)
BuildRequires: perl(Moo)
BuildRequires: perl(Moo::Role)
Requires: perl(Log::Any)
Requires: perl(Moo::Role)
Provides: perl(MooX::Log::Any) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
A logging role building a very lightweight wrapper to Log::Any for use with
your Moo or Moose classes. Connecting a Log::Any::Adapter should be
performed prior to logging the first log message, otherwise nothing will
happen, just like with Log::Any
Using the logger within a class is as simple as consuming a role:
package MyClass;
use Moo;
with 'MooX::Log::Any';
sub dummy {
my $self = shift;
$self->log->info("Dummy log entry");
}
The logger needs to be setup before using the logger, which could happen in
the main application:
package main;
use Log::Any::Adapter;
# Send all logs to Log::Log4perl
Log::Any::Adapter->set('Log4perl')
use MyClass;
my $myclass = MyClass->new();
$myclass->log->info("In my class"); # Access the log of the object
$myclass->dummy; # Will log "Dummy log entry"
%prep
%autosetup -n %{cpan_name}-%{cpan_version}
%build
perl Makefile.PL INSTALLDIRS=vendor
%make_build
%check
make test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%doc Changes README README.md
%license LICENSE
%changelog