Log-ger-0.042/0000775000175000017500000000000014543456156010466 5ustar u1u1Log-ger-0.042/Makefile.PL0000644000175000017500000000233614543456156012442 0ustar u1u1# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.031. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "A lightweight, flexible logging framework", "AUTHOR" => "perlancar ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Log-ger", "LICENSE" => "perl", "NAME" => "Log::ger", "PREREQ_PM" => { "Data::Dumper" => 0, "parent" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98" }, "VERSION" => "0.042", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Data::Dumper" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98", "parent" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Log-ger-0.042/META.yml0000644000175000017500000003550614543456156011746 0ustar u1u1--- abstract: 'A lightweight, flexible logging framework' author: - 'perlancar ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0.98' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.031, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Log-ger provides: Log::ger: file: lib/Log/ger.pm version: '0.042' Log::ger::Filter: file: lib/Log/ger/Filter.pm version: '0.042' Log::ger::Filter::Code: file: lib/Log/ger/Filter/Code.pm version: '0.042' Log::ger::Format: file: lib/Log/ger/Format.pm version: '0.042' Log::ger::Format::Default: file: lib/Log/ger/Format/Default.pm version: '0.042' Log::ger::Format::MultilevelLog: file: lib/Log/ger/Format/MultilevelLog.pm version: '0.042' Log::ger::Format::None: file: lib/Log/ger/Format/None.pm version: '0.042' Log::ger::Heavy: file: lib/Log/ger/Heavy.pm version: '0.042' Log::ger::Layout: file: lib/Log/ger/Layout.pm version: '0.042' Log::ger::Output: file: lib/Log/ger/Output.pm version: '0.042' Log::ger::Output::Array: file: lib/Log/ger/Output/Array.pm version: '0.042' Log::ger::Output::Null: file: lib/Log/ger/Output/Null.pm version: '0.042' Log::ger::Output::String: file: lib/Log/ger/Output/String.pm version: '0.042' Log::ger::Plugin: file: lib/Log/ger/Plugin.pm version: '0.042' Log::ger::Plugin::MultilevelLog: file: lib/Log/ger/Plugin/MultilevelLog.pm version: '0.042' Log::ger::Util: file: lib/Log/ger/Util.pm version: '0.042' recommends: Data::Dmp: '0.242' Sub::Name: '0' requires: Data::Dumper: '0' parent: '0' strict: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Log-ger homepage: https://metacpan.org/release/Log-ger repository: git://github.com/perlancar/perl-Log-ger.git version: '0.042' x_Dist_Zilla: perl: version: '5.038002' plugins: - class: Dist::Zilla::Plugin::InsertBlock name: InsertBlock version: '0.103' - class: Dist::Zilla::Plugin::PERLANCAR::CheckPendingRelease name: '@Author::PERLANCAR/PERLANCAR::CheckPendingRelease' version: '0.001' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Author::PERLANCAR/@Filter/GatherDir' version: '6.031' - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::PERLANCAR/@Filter/PruneCruft' version: '6.031' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::PERLANCAR/@Filter/ManifestSkip' version: '6.031' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::PERLANCAR/@Filter/MetaYAML' version: '6.031' - class: Dist::Zilla::Plugin::License name: '@Author::PERLANCAR/@Filter/License' version: '6.031' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Author::PERLANCAR/@Filter/PodCoverageTests' version: '6.031' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::PERLANCAR/@Filter/PodSyntaxTests' version: '6.031' - class: Dist::Zilla::Plugin::ExtraTests name: '@Author::PERLANCAR/@Filter/ExtraTests' version: '6.031' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/@Filter/ExecDir' version: '6.031' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::PERLANCAR/@Filter/ShareDir' version: '6.031' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::PERLANCAR/@Filter/MakeMaker' version: '6.031' - class: Dist::Zilla::Plugin::Manifest name: '@Author::PERLANCAR/@Filter/Manifest' version: '6.031' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::PERLANCAR/@Filter/ConfirmRelease' version: '6.031' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/ExecDir script' version: '6.031' - class: Dist::Zilla::Plugin::PERLANCAR::BeforeBuild name: '@Author::PERLANCAR/PERLANCAR::BeforeBuild' version: '0.610' - class: Dist::Zilla::Plugin::Rinci::AbstractFromMeta name: '@Author::PERLANCAR/Rinci::AbstractFromMeta' version: '0.10' - class: Dist::Zilla::Plugin::PodnameFromFilename name: '@Author::PERLANCAR/PodnameFromFilename' version: '0.02' - class: Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec config: Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec' version: '0.064' - class: Dist::Zilla::Plugin::PERLANCAR::MetaResources name: '@Author::PERLANCAR/PERLANCAR::MetaResources' version: '0.043' - class: Dist::Zilla::Plugin::CheckChangeLog name: '@Author::PERLANCAR/CheckChangeLog' version: '0.05' - class: Dist::Zilla::Plugin::CheckMetaResources name: '@Author::PERLANCAR/CheckMetaResources' version: '0.001' - class: Dist::Zilla::Plugin::CheckSelfDependency config: Dist::Zilla::Plugin::CheckSelfDependency: finder: - ':InstallModules' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Author::PERLANCAR/CheckSelfDependency' version: '0.011' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: git_version: 2.25.1 include_authors: 0 include_releaser: 1 order_by: name paths: [] name: '@Author::PERLANCAR/Git::Contributors' version: '0.036' - class: Dist::Zilla::Plugin::CopyrightYearFromGit name: '@Author::PERLANCAR/CopyrightYearFromGit' version: '0.009' - class: Dist::Zilla::Plugin::IfBuilt name: '@Author::PERLANCAR/IfBuilt' version: '0.02' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::PERLANCAR/MetaJSON' version: '6.031' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::PERLANCAR/MetaConfig' version: '6.031' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Author::PERLANCAR/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.031' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: 1 inherit_version: 1 meta_noindex: 1 Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Author::PERLANCAR/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::PERLANCAR::Authority name: '@Author::PERLANCAR/PERLANCAR::Authority' version: '0.001' - class: Dist::Zilla::Plugin::OurDate name: '@Author::PERLANCAR/OurDate' version: '0.040' - class: Dist::Zilla::Plugin::OurDist name: '@Author::PERLANCAR/OurDist' version: '0.02' - class: Dist::Zilla::Plugin::OurPkgVersion name: '@Author::PERLANCAR/OurPkgVersion' version: '0.21' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':PerlExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.019' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.019' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Default/SingleEncoding' version: '4.019' - class: Pod::Weaver::Section::Name name: '@Default/Name' version: '4.019' - class: Pod::Weaver::Section::Version name: '@Default/Version' version: '4.019' - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: '4.019' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.019' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.019' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.019' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.019' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.019' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.019' - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: '4.019' - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: '4.019' - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: '4.019' - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: '4.019' name: '@Author::PERLANCAR/PodWeaver' version: '4.010' - class: Dist::Zilla::Plugin::PruneFiles name: '@Author::PERLANCAR/PruneFiles' version: '6.031' - class: Dist::Zilla::Plugin::Pod2Readme name: '@Author::PERLANCAR/Pod2Readme' version: '0.004' - class: Dist::Zilla::Plugin::Rinci::AddPrereqs name: '@Author::PERLANCAR/Rinci::AddPrereqs' version: '0.145' - class: Dist::Zilla::Plugin::Rinci::AddToDb name: '@Author::PERLANCAR/Rinci::AddToDb' version: '0.020' - class: Dist::Zilla::Plugin::Rinci::EmbedValidator name: '@Author::PERLANCAR/Rinci::EmbedValidator' version: '0.251' - class: Dist::Zilla::Plugin::SetScriptShebang name: '@Author::PERLANCAR/SetScriptShebang' version: '0.01' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: 0 fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Author::PERLANCAR/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::Test::Perl::Critic::Subset config: Dist::Zilla::Plugin::Test::Perl::Critic::Subset: finder: - ':ExecFiles' - ':InstallModules' - ':TestFiles' name: '@Author::PERLANCAR/Test::Perl::Critic::Subset' version: 3.001.006 - class: Dist::Zilla::Plugin::Test::Rinci name: '@Author::PERLANCAR/Test::Rinci' version: '0.040' - class: Dist::Zilla::Plugin::StaticInstall config: Dist::Zilla::Plugin::StaticInstall: dry_run: 0 mode: on name: '@Author::PERLANCAR/StaticInstall' version: '0.012' - class: Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest name: '@Author::PERLANCAR/EnsureSQLSchemaVersionedTest' version: '0.03' - class: Dist::Zilla::Plugin::Acme::CPANModules::Blacklist name: '@Author::PERLANCAR/Acme::CPANModules::Blacklist' version: '0.002' - class: Dist::Zilla::Plugin::Prereqs::EnsureVersion name: '@Author::PERLANCAR/Prereqs::EnsureVersion' version: '0.050' - class: Dist::Zilla::Plugin::Prereqs::CheckCircular name: '@Author::PERLANCAR/Prereqs::CheckCircular' version: '0.007' - class: Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple name: '@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple' version: '0.04' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: '6.031' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '6.031' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: recommends name: RuntimeRecommends version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.031' - class: Dist::Zilla::Plugin::FinderCode name: '@Author::PERLANCAR/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.031' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: '6.031' x_authority: cpan:PERLANCAR x_contributors: - 'James Raspass ' x_generated_by_perl: v5.38.2 x_serialization_backend: 'YAML::Tiny version 1.74' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_static_install: 1 Log-ger-0.042/dist.ini0000644000175000017500000000064614543456156012136 0ustar u1u1;--------------------------------- author = perlancar copyright_holder = perlancar license = Perl_5 ;--------------------------------- version = 0.042 name = Log-ger [InsertBlock] [@Author::PERLANCAR] :version=0.610 [Prereqs / TestRequires] Test::More=0.98 [Prereqs] parent=0 strict=0 warnings=0 Data::Dumper=0 [Prereqs / RuntimeRecommends] Data::Dmp=0.242 Sub::Name=0 Log-ger-0.042/META.json0000644000175000017500000005444514543456156012121 0ustar u1u1{ "abstract" : "A lightweight, flexible logging framework", "author" : [ "perlancar " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.031, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Log-ger", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "recommends" : { "Data::Dmp" : "0.242", "Sub::Name" : "0" }, "requires" : { "Data::Dumper" : "0", "parent" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.98" } } }, "provides" : { "Log::ger" : { "file" : "lib/Log/ger.pm", "version" : "0.042" }, "Log::ger::Filter" : { "file" : "lib/Log/ger/Filter.pm", "version" : "0.042" }, "Log::ger::Filter::Code" : { "file" : "lib/Log/ger/Filter/Code.pm", "version" : "0.042" }, "Log::ger::Format" : { "file" : "lib/Log/ger/Format.pm", "version" : "0.042" }, "Log::ger::Format::Default" : { "file" : "lib/Log/ger/Format/Default.pm", "version" : "0.042" }, "Log::ger::Format::MultilevelLog" : { "file" : "lib/Log/ger/Format/MultilevelLog.pm", "version" : "0.042" }, "Log::ger::Format::None" : { "file" : "lib/Log/ger/Format/None.pm", "version" : "0.042" }, "Log::ger::Heavy" : { "file" : "lib/Log/ger/Heavy.pm", "version" : "0.042" }, "Log::ger::Layout" : { "file" : "lib/Log/ger/Layout.pm", "version" : "0.042" }, "Log::ger::Output" : { "file" : "lib/Log/ger/Output.pm", "version" : "0.042" }, "Log::ger::Output::Array" : { "file" : "lib/Log/ger/Output/Array.pm", "version" : "0.042" }, "Log::ger::Output::Null" : { "file" : "lib/Log/ger/Output/Null.pm", "version" : "0.042" }, "Log::ger::Output::String" : { "file" : "lib/Log/ger/Output/String.pm", "version" : "0.042" }, "Log::ger::Plugin" : { "file" : "lib/Log/ger/Plugin.pm", "version" : "0.042" }, "Log::ger::Plugin::MultilevelLog" : { "file" : "lib/Log/ger/Plugin/MultilevelLog.pm", "version" : "0.042" }, "Log::ger::Util" : { "file" : "lib/Log/ger/Util.pm", "version" : "0.042" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Log-ger" }, "homepage" : "https://metacpan.org/release/Log-ger", "repository" : { "type" : "git", "url" : "git://github.com/perlancar/perl-Log-ger.git", "web" : "https://github.com/perlancar/perl-Log-ger" } }, "version" : "0.042", "x_Dist_Zilla" : { "perl" : { "version" : "5.038002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::InsertBlock", "name" : "InsertBlock", "version" : "0.103" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::CheckPendingRelease", "name" : "@Author::PERLANCAR/PERLANCAR::CheckPendingRelease", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Author::PERLANCAR/@Filter/GatherDir", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Author::PERLANCAR/@Filter/PruneCruft", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::PERLANCAR/@Filter/ManifestSkip", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::PERLANCAR/@Filter/MetaYAML", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::PERLANCAR/@Filter/License", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Author::PERLANCAR/@Filter/PodCoverageTests", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::PERLANCAR/@Filter/PodSyntaxTests", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Author::PERLANCAR/@Filter/ExtraTests", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/@Filter/ExecDir", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::PERLANCAR/@Filter/ShareDir", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Author::PERLANCAR/@Filter/MakeMaker", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::PERLANCAR/@Filter/Manifest", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::PERLANCAR/@Filter/ConfirmRelease", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/ExecDir script", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::BeforeBuild", "name" : "@Author::PERLANCAR/PERLANCAR::BeforeBuild", "version" : "0.610" }, { "class" : "Dist::Zilla::Plugin::Rinci::AbstractFromMeta", "name" : "@Author::PERLANCAR/Rinci::AbstractFromMeta", "version" : "0.10" }, { "class" : "Dist::Zilla::Plugin::PodnameFromFilename", "name" : "@Author::PERLANCAR/PodnameFromFilename", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec", "config" : { "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec", "version" : "0.064" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::MetaResources", "name" : "@Author::PERLANCAR/PERLANCAR::MetaResources", "version" : "0.043" }, { "class" : "Dist::Zilla::Plugin::CheckChangeLog", "name" : "@Author::PERLANCAR/CheckChangeLog", "version" : "0.05" }, { "class" : "Dist::Zilla::Plugin::CheckMetaResources", "name" : "@Author::PERLANCAR/CheckMetaResources", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::CheckSelfDependency", "config" : { "Dist::Zilla::Plugin::CheckSelfDependency" : { "finder" : [ ":InstallModules" ] }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Author::PERLANCAR/CheckSelfDependency", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "git_version" : "2.25.1", "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", "paths" : [] } }, "name" : "@Author::PERLANCAR/Git::Contributors", "version" : "0.036" }, { "class" : "Dist::Zilla::Plugin::CopyrightYearFromGit", "name" : "@Author::PERLANCAR/CopyrightYearFromGit", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::IfBuilt", "name" : "@Author::PERLANCAR/IfBuilt", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::PERLANCAR/MetaJSON", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::PERLANCAR/MetaConfig", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Author::PERLANCAR/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.031" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Author::PERLANCAR/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::Authority", "name" : "@Author::PERLANCAR/PERLANCAR::Authority", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::OurDate", "name" : "@Author::PERLANCAR/OurDate", "version" : "0.040" }, { "class" : "Dist::Zilla::Plugin::OurDist", "name" : "@Author::PERLANCAR/OurDist", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::OurPkgVersion", "name" : "@Author::PERLANCAR/OurPkgVersion", "version" : "0.21" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":PerlExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.019" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.019" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Default/SingleEncoding", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.019" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.019" } ] } }, "name" : "@Author::PERLANCAR/PodWeaver", "version" : "4.010" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "@Author::PERLANCAR/PruneFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::Pod2Readme", "name" : "@Author::PERLANCAR/Pod2Readme", "version" : "0.004" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddPrereqs", "name" : "@Author::PERLANCAR/Rinci::AddPrereqs", "version" : "0.145" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddToDb", "name" : "@Author::PERLANCAR/Rinci::AddToDb", "version" : "0.020" }, { "class" : "Dist::Zilla::Plugin::Rinci::EmbedValidator", "name" : "@Author::PERLANCAR/Rinci::EmbedValidator", "version" : "0.251" }, { "class" : "Dist::Zilla::Plugin::SetScriptShebang", "name" : "@Author::PERLANCAR/SetScriptShebang", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Author::PERLANCAR/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::Test::Perl::Critic::Subset", "config" : { "Dist::Zilla::Plugin::Test::Perl::Critic::Subset" : { "finder" : [ ":ExecFiles", ":InstallModules", ":TestFiles" ] } }, "name" : "@Author::PERLANCAR/Test::Perl::Critic::Subset", "version" : "3.001.006" }, { "class" : "Dist::Zilla::Plugin::Test::Rinci", "name" : "@Author::PERLANCAR/Test::Rinci", "version" : "0.040" }, { "class" : "Dist::Zilla::Plugin::StaticInstall", "config" : { "Dist::Zilla::Plugin::StaticInstall" : { "dry_run" : 0, "mode" : "on" } }, "name" : "@Author::PERLANCAR/StaticInstall", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest", "name" : "@Author::PERLANCAR/EnsureSQLSchemaVersionedTest", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::Acme::CPANModules::Blacklist", "name" : "@Author::PERLANCAR/Acme::CPANModules::Blacklist", "version" : "0.002" }, { "class" : "Dist::Zilla::Plugin::Prereqs::EnsureVersion", "name" : "@Author::PERLANCAR/Prereqs::EnsureVersion", "version" : "0.050" }, { "class" : "Dist::Zilla::Plugin::Prereqs::CheckCircular", "name" : "@Author::PERLANCAR/Prereqs::CheckCircular", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple", "name" : "@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "recommends" } }, "name" : "RuntimeRecommends", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.031" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Author::PERLANCAR/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.031" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.031" } }, "x_authority" : "cpan:PERLANCAR", "x_contributors" : [ "James Raspass " ], "x_generated_by_perl" : "v5.38.2", "x_serialization_backend" : "Cpanel::JSON::XS version 4.37", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1 } Log-ger-0.042/t/0000775000175000017500000000000014543456156010731 5ustar u1u1Log-ger-0.042/t/author-pod-syntax.t0000644000175000017500000000045414543456156014525 0ustar u1u1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Log-ger-0.042/t/format-none.t0000644000175000017500000000104714543456156013343 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Output (); package My::P1; use Log::ger::Format 'None'; use Log::ger; sub x { log_warn({a=>1, b=>2}); } package My::P2; use Log::ger; sub x { log_warn({a=>3, b=>4}, ""); } package main; subtest "basics" => sub { my $ary = []; Log::ger::Output->set('Array', array => $ary); My::P1::x(); is_deeply($ary, [{a=>1, b=>2}]); splice @$ary; My::P2::x(); ok(!ref($ary->[0])) or diag explain $ary; like($ary->[0], qr/^HASH/); }; done_testing; Log-ger-0.042/t/01-basic.t0000644000175000017500000001346314543456156012422 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; package My::P1; use Log::ger; BEGIN { log_trace(""); } # just to test that sub exists package My::P2; package My::P3; # test get_logger use Log::ger (); BEGIN { my $log = Log::ger->get_logger; $log->trace(""); } # just to test that method exists package main; use Log::ger::Util; subtest numeric_level => sub { is(Log::ger::Util::numeric_level(10), 10); is(Log::ger::Util::numeric_level("info"), 40); # XXX check unknown level }; subtest string_level => sub { is(Log::ger::Util::string_level(10), "fatal"); is(Log::ger::Util::string_level("info"), "info"); is(Log::ger::Util::string_level("warning"), "warn"); # XXX check unknown level }; subtest "basics" => sub { subtest "import" => sub { my $str = ""; require Log::ger::Output; Log::ger::Output->set('String', string => \$str); My::P1::log_warn("warn"); My::P1::log_debug("debug"); is($str, "warn\n"); { $str = ""; Log::ger::Util::set_level(50); My::P1::log_warn("warn"); My::P1::log_debug("debug"); is($str, "warn\ndebug\n"); } }; subtest "init_target package" => sub { my $str = ""; Log::ger::Util::set_level(30); require Log::ger::Output; Log::ger::Output->set('String', string => \$str); Log::ger::init_target(package => 'My::P2'); My::P2::log_warn("warn"); My::P2::log_debug("debug"); is($str, "warn\n"); }; subtest "init_target hash" => sub { my $str = ""; require Log::ger::Output; Log::ger::Output->set('String', string => \$str); Log::ger::Util::set_level(30); my $h = {}; Log::ger::init_target(hash => $h); is(ref $h, 'HASH'); $h->{fatal}("fatal"); $h->{error}("error"); $h->{warn}("warn"); $h->{info}("info"); $h->{debug}("debug"); $h->{trace}("trace"); is($str, "fatal\nerror\nwarn\n"); }; subtest "init_target object" => sub { my $str = ""; require Log::ger::Output; Log::ger::Output->set('String', string => \$str); Log::ger::Util::set_level(30); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\nerror\nwarn\n"); subtest "level=off (0)" => sub { $str = ""; Log::ger::Util::set_level(0); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, ""); }; subtest "level=fatal (10)" => sub { $str = ""; Log::ger::Util::set_level(10); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\n"); }; subtest "level=error (20)" => sub { $str = ""; Log::ger::Util::set_level(20); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\nerror\n"); }; subtest "level=info (40)" => sub { $str = ""; Log::ger::Util::set_level(40); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\nerror\nwarn\ninfo\n"); }; subtest "level=debug (50)" => sub { $str = ""; Log::ger::Util::set_level(50); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\nerror\nwarn\ninfo\ndebug\n"); }; subtest "level=trace (60)" => sub { $str = ""; Log::ger::Util::set_level(60); my $o = bless [], "My::Logger"; Log::ger::init_target(object => $o); $o->fatal("fatal"); $o->error("error"); $o->warn("warn"); $o->info("info"); $o->debug("debug"); $o->trace("trace"); is($str, "fatal\nerror\nwarn\ninfo\ndebug\ntrace\n"); }; }; }; subtest "switch output" => sub { require Log::ger::Output; my $str = ""; my $ary = []; my $h = {}; Log::ger::add_target(hash => $h); Log::ger::Output->set('String', string => \$str); $h->{warn}("warn1"); is_deeply($str, "warn1\n"); is_deeply($ary, []); Log::ger::Output->set('Array', array => $ary); $h->{warn}("warn2"); is_deeply($str, "warn1\n"); is_deeply($ary, ["warn2"]); Log::ger::Output->set('String', string => \$str); $h->{warn}("warn3"); is_deeply($str, "warn1\nwarn3\n"); is_deeply($ary, ["warn2"]); Log::ger::Output->set('Array', array => $ary); $h->{warn}("warn4"); is_deeply($str, "warn1\nwarn3\n"); is_deeply($ary, ["warn2", "warn4"]); }; DONE_TESTING: done_testing; Log-ger-0.042/t/no-format.t0000644000175000017500000000114614543456156013020 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Output (); package My::P1; use Log::ger::Heavy; { local $Log::ger::Default_Hooks{create_formatter} = []; Log::ger->import; } sub x { log_warn({a=>1, b=>2}); } package My::P2; use Log::ger; sub x { log_warn({a=>3, b=>4}, ""); } package main; subtest "basics" => sub { my $ary = []; Log::ger::Output->set('Array', array => $ary); My::P1::x(); is_deeply($ary, [{a=>1, b=>2}]); splice @$ary; My::P2::x(); ok(!ref($ary->[0])) or diag explain $ary; like($ary->[0], qr/^HASH/); }; done_testing; Log-ger-0.042/t/plugin-multilevellog.t0000644000175000017500000000052614543456156015277 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Util; our $str; use Log::ger::Output 'String', string => \$str; package My::P1; use Log::ger::Format 'MultilevelLog'; use Log::ger; sub x { log(30, "warnmsg"); log(50, "debugmsg"); } package main; $str = ""; My::P1::x(); is($str, "warnmsg\n"); done_testing; Log-ger-0.042/t/level.t0000644000175000017500000000131414543456156012222 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger (); use Log::ger::Util; BEGIN { %Log::ger::Levels = ( foo => 10, bar => 20, baz => 30, qux => 40, ); } package My::P1; use Log::ger; package main; subtest "basics" => sub { my $str = ""; require Log::ger::Output; Log::ger::Output->set('String', string => \$str); My::P1::log_foo("foo"); My::P1::log_bar("bar"); My::P1::log_baz("baz"); My::P1::log_qux("qux"); is($str, "foo\nbar\nbaz\n"); { $str = ""; Log::ger::Util::set_level("foo"); My::P1::log_foo("foo"); My::P1::log_bar("bar"); is($str, "foo\n"); } }; done_testing; Log-ger-0.042/t/author-pod-coverage.t0000644000175000017500000000056714543456156014777 0ustar u1u1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use strict; use warnings; use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Log-ger-0.042/t/output-null.t0000644000175000017500000000101414543456156013420 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Util; package My::P1; use Log::ger; package main; subtest "basics" => sub { Log::ger::Util::reset_hooks('create_outputter'); require Log::ger::Output; Log::ger::Output->set('Null'); my $h = {}; Log::ger::init_target(hash => $h); is(ref $h, 'HASH'); $h->{fatal}("fatal"); $h->{error}("error"); $h->{warn}("warn"); $h->{info}("info"); $h->{debug}("debug"); $h->{trace}("trace"); ok(1); }; done_testing; Log-ger-0.042/t/00-compile.t0000644000175000017500000000351514543456156012765 0ustar u1u1use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 16 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Log/ger.pm', 'Log/ger/Filter.pm', 'Log/ger/Filter/Code.pm', 'Log/ger/Format.pm', 'Log/ger/Format/Default.pm', 'Log/ger/Format/MultilevelLog.pm', 'Log/ger/Format/None.pm', 'Log/ger/Heavy.pm', 'Log/ger/Layout.pm', 'Log/ger/Output.pm', 'Log/ger/Output/Array.pm', 'Log/ger/Output/Null.pm', 'Log/ger/Output/String.pm', 'Log/ger/Plugin.pm', 'Log/ger/Plugin/MultilevelLog.pm', 'Log/ger/Util.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; Log-ger-0.042/t/output-string.t0000644000175000017500000000214014543456156013755 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Util; package My::P1; use Log::ger; package My::P2; package main; subtest "opt:append_newline=1" => sub { my $str = ""; Log::ger::Util::reset_hooks('create_outputter'); require Log::ger::Output; Log::ger::Output->set('String', string => \$str, append_newline => 1); my $h = {}; Log::ger::init_target(hash => $h); is(ref $h, 'HASH'); $h->{fatal}("fatal"); $h->{error}("error"); $h->{warn}("warn"); $h->{info}("info"); $h->{debug}("debug"); $h->{trace}("trace"); is($str, "fatal\nerror\nwarn\n"); }; subtest "opt:append_newline=0" => sub { my $str = ""; Log::ger::Util::reset_hooks('create_outputter'); require Log::ger::Output; Log::ger::Output->set('String', string => \$str, append_newline => 0); my $h = {}; Log::ger::init_target(hash => $h); is(ref $h, 'HASH'); $h->{fatal}("fatal"); $h->{error}("error"); $h->{warn}("warn"); $h->{info}("info"); $h->{debug}("debug"); $h->{trace}("trace"); is($str, "fatalerrorwarn"); }; done_testing; Log-ger-0.042/t/author-critic.t0000644000175000017500000000156114543456156013674 0ustar u1u1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.006 use Test::Perl::Critic (-profile => "") x!! -e ""; my $filenames = ['lib/Log/ger.pm','lib/Log/ger/Filter.pm','lib/Log/ger/Filter/Code.pm','lib/Log/ger/Format.pm','lib/Log/ger/Format/Default.pm','lib/Log/ger/Format/MultilevelLog.pm','lib/Log/ger/Format/None.pm','lib/Log/ger/Heavy.pm','lib/Log/ger/Layout.pm','lib/Log/ger/Output.pm','lib/Log/ger/Output/Array.pm','lib/Log/ger/Output/Null.pm','lib/Log/ger/Output/String.pm','lib/Log/ger/Plugin.pm','lib/Log/ger/Plugin/MultilevelLog.pm','lib/Log/ger/Util.pm']; unless ($filenames && @$filenames) { $filenames = -d "blib" ? ["blib"] : ["lib"]; } all_critic_ok(@$filenames); Log-ger-0.042/t/output-array.t0000644000175000017500000000103314543456156013565 0ustar u1u1#!perl use strict; use warnings; use Test::More 0.98; use Log::ger::Util; package My::P1; use Log::ger; package main; subtest "basics" => sub { my $ary = []; require Log::ger::Output; Log::ger::Output->set('Array', array => $ary); my $h = {}; Log::ger::init_target(hash => $h); is(ref $h, 'HASH'); $h->{fatal}("fatal"); $h->{error}("error"); $h->{warn}("warn"); $h->{info}("info"); $h->{debug}("debug"); $h->{trace}("trace"); is_deeply($ary, [qw/fatal error warn/]); }; done_testing; Log-ger-0.042/LICENSE0000644000175000017500000004664714543456156011512 0ustar u1u1This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Log-ger-0.042/lib/0000775000175000017500000000000014543456156011234 5ustar u1u1Log-ger-0.042/lib/Log/0000775000175000017500000000000014543456156011755 5ustar u1u1Log-ger-0.042/lib/Log/ger.pm0000644000175000017500000002714114543456156013073 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION #IFUNBUILT # use strict 'subs', 'vars'; # use warnings; #END IFUNBUILT our $re_addr = qr/\(0x([0-9a-f]+)/o; our %Levels = ( fatal => 10, error => 20, warn => 30, info => 40, debug => 50, trace => 60, ); our %Level_Aliases = ( off => 0, warning => 30, ); our $Current_Level = 30; our $Caller_Depth_Offset = 0; # a flag that can be used by null output to skip using formatter our $_outputter_is_null; our $_dumper; our %Global_Hooks; # in Log/ger/Heavy.pm # our %Default_Hooks = ( our %Package_Targets; # key = package name, value = \%per_target_conf our %Per_Package_Hooks; # key = package name, value = { phase => hooks, ... } our %Hash_Targets; # key = hash address, value = [$hashref, \%per_target_conf] our %Per_Hash_Hooks; # key = hash address, value = { phase => hooks, ... } our %Object_Targets; # key = object address, value = [$obj, \%per_target_conf] our %Per_Object_Hooks; # key = object address, value = { phase => hooks, ... } my $sub0 = sub {0}; my $sub1 = sub {1}; my $default_null_routines; sub install_routines { my ($target, $target_arg, $routines, $name_routines) = @_; if ($name_routines && !defined &subname) { if (eval { require Sub::Name; 1 }) { *subname = \&Sub::Name::subname; } else { *subname = sub {}; } } if ($target eq 'package') { #IFUNBUILT # no warnings 'redefine'; #END IFUNBUILT for my $r (@$routines) { my ($code, $name, $lnum, $type) = @$r; next unless $type =~ /_sub\z/; #print "D:installing $name to package $target_arg\n"; *{"$target_arg\::$name"} = $code; subname("$target_arg\::$name", $code) if $name_routines; } } elsif ($target eq 'object') { #IFUNBUILT # no warnings 'redefine'; #END IFUNBUILT my $pkg = ref $target_arg; for my $r (@$routines) { my ($code, $name, $lnum, $type) = @$r; next unless $type =~ /_method\z/; *{"$pkg\::$name"} = $code; subname("$pkg\::$name", $code) if $name_routines; } } elsif ($target eq 'hash') { for my $r (@$routines) { my ($code, $name, $lnum, $type) = @$r; next unless $type =~ /_sub\z/; $target_arg->{$name} = $code; } } } sub add_target { my ($target_type, $target_name, $per_target_conf, $replace) = @_; $replace = 1 unless defined $replace; if ($target_type eq 'package') { unless ($replace) { return if $Package_Targets{$target_name} } $Package_Targets{$target_name} = $per_target_conf; } elsif ($target_type eq 'object') { my ($addr) = "$target_name" =~ $re_addr; unless ($replace) { return if $Object_Targets{$addr} } $Object_Targets{$addr} = [$target_name, $per_target_conf]; } elsif ($target_type eq 'hash') { my ($addr) = "$target_name" =~ $re_addr; unless ($replace) { return if $Hash_Targets{$addr} } $Hash_Targets{$addr} = [$target_name, $per_target_conf]; } } sub _set_default_null_routines { $default_null_routines ||= [ (map {( [$sub0, "log_$_", $Levels{$_}, 'logger_sub'], [$Levels{$_} > $Current_Level ? $sub0 : $sub1, "log_is_$_", $Levels{$_}, 'level_checker_sub'], [$sub0, $_, $Levels{$_}, 'logger_method'], [$Levels{$_} > $Current_Level ? $sub0 : $sub1, "is_$_", $Levels{$_}, 'level_checker_method'], )} keys %Levels), ]; } sub get_logger { my ($package, %per_target_conf) = @_; my $caller = caller(0); $per_target_conf{category} = $caller if !defined($per_target_conf{category}); my $obj = []; $obj =~ $re_addr; my $pkg = "Log::ger::Obj$1"; bless $obj, $pkg; add_target(object => $obj, \%per_target_conf); if (keys %Global_Hooks) { require Log::ger::Heavy; init_target(object => $obj, \%per_target_conf); } else { # if we haven't added any hooks etc, skip init_target() process and use # this preconstructed routines as shortcut, to save startup overhead _set_default_null_routines(); install_routines(object => $obj, $default_null_routines, 0); } $obj; # XXX add DESTROY to remove from list of targets } sub _import_to { my ($package, $target_pkg, %per_target_conf) = @_; $per_target_conf{category} = $target_pkg if !defined($per_target_conf{category}); add_target(package => $target_pkg, \%per_target_conf); if (keys %Global_Hooks) { require Log::ger::Heavy; init_target(package => $target_pkg, \%per_target_conf); } else { # if we haven't added any hooks etc, skip init_target() process and use # this preconstructed routines as shortcut, to save startup overhead _set_default_null_routines(); install_routines(package => $target_pkg, $default_null_routines, 0); } } sub import { my ($package, %per_target_conf) = @_; my $caller = caller(0); $package->_import_to($caller, %per_target_conf); } 1; # ABSTRACT: A lightweight, flexible logging framework __END__ =pod =encoding UTF-8 =head1 NAME Log::ger - A lightweight, flexible logging framework =head1 VERSION version 0.042 =head1 SYNOPSIS =head2 Producing logs In your module (producer): package MyModule; # this will install some logger routines. by default: log_trace, log_debug, # log_info, log_warn, log_error, and log_fatal. level checker routines are also # installed: log_is_trace, log_is_debug, and so on. use Log::ger; sub foo { ... # produce some logs. no need to configure output or level. by default # output goes nowhere. log_error "an error occured: %03d - %s", $errcode, $errmsg; ... # the logging routines (log_*) can automatically dump data structures log_debug "http response: %s", $http; # log_fatal does not die by default, if you want to then die() explicitly. # but there are plugins that let you do this or provide log_die etc. if (blah) { log_fatal "..."; die } # use the level checker routines (log_is_*) to avoid doing unnecessary # heavy calculation if (log_is_trace) { my $res = some_heavy_calculation(); log_trace "The result is %s", $res; } } 1; =head2 Consuming logs =head3 Choosing an output In your application (consumer/listener): use MyModule; use Log::ger::Output 'Screen'; # configure output # level is by default 'warn' foo(); # the error message is shown, but debug/trace messages are not. =head3 Choosing multiple outputs Instead of screen, you can output to multiple outputs (including multiple files): use Log::ger::Output 'Composite' => ( outputs => { Screen => {}, File => [ {conf=>{path=>'/path/to/app.log'}}, ... ], ... }, ); See L for more examples. There is also L that wraps this in a simple interface so you just need to do: # In your application or script: use Log::ger::App; use MyModule; =head3 Choosing level One way to set level: use Log::ger::Util; Log::ger::Util::set_level('debug'); # be more verbose foo(); # the error message as well as debug message are now shown, but the trace is not There are better ways, e.g. letting users configure log level via configuration file or command-line option. See L for more details. =head1 DESCRIPTION Log::ger is yet another logging framework with the following features: =over =item * Separation of producers and consumers/listeners Like L, this offers a very easy way for modules to produce some logs without having to configure anything. Configuring output, level, etc can be done in the application as log consumers/listeners. To read more about this, see the documentation of L or L (but nevertheless see L on why you might prefer Log::ger to Log::Any). =item * Lightweight and fast B No non-core dependencies, extra functionalities are provided in separate distributions to be pulled as needed. B Only ~0.5-1ms. For comparison, L ~0.2-0.5ms, L ~2ms, L (v0.15) ~2-3ms, Log::Any (v1.049) ~8-10ms, L ~35ms. This is measured on a 2014-2015 PC and before doing any output configuration. I strive to make C statement to be roughly as light as C or C so the impact of adding the statement is really minimal and you can just add logging without much thought to most of your modules. This is important to me because I want logging to be pervasive. To test for yourself, try e.g. with L: % bencher-code 'use Log::ger' 'use Log::Any' --startup B. Low null-/stealth-logging overhead, about 1.5x faster than Log::Any, 3x faster than Log4perl, 5x faster than L, ~40x faster than L, and ~100x faster than L. For more benchmarks, see L. B There is a plugin to optimize away unneeded logging statements, like assertion/conditional compilation, so they have zero runtime performance cost. See L. Being lightweight means the module can be used more universally, from CLI to long-running daemons to inside routines with tight loops. =item * Flexible B Can be used in a procedural or OO style. Log::ger can mimic the interface of L, L, L, or some other popular logging frameworks, to ease migration or adjust with your personal style. B Each importer package can use its own format/layout, output. For example, a module that is migrated from Log::Any uses Log::Any-style logging, while another uses native Log::ger style, and yet some other uses block formatting like Log::Contextual. This eases code migration and teamwork. Each module author can preserve her own logging style, if wanted, and all the modules still use the same framework. B Outputs and levels can be changed anytime during run-time and logger routines will be updated automatically. This is useful in situation like a long-running server application: you can turn on tracing logs temporarily to debug problems, then turn them off again, without restarting your server. B There are modules to interop with Log::Any, either consume Log::Any logs (see L) or produce logs to be consumed by Log::Any (see L). B See C, C, C, C. Writing an output module in Log::ger is easier than writing a Log::Any::Adapter::*. =back For more documentation, start with L. =for Pod::Coverage ^(.+)$ =head1 SEE ALSO Some other popular logging frameworks: L, L, L, L, L. If you still prefer debugging using the good old C, there's L. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/0000775000175000017500000000000014543456156012532 5ustar u1u1Log-ger-0.042/lib/Log/ger/Format/0000775000175000017500000000000014543456156013762 5ustar u1u1Log-ger-0.042/lib/Log/ger/Format/None.pm0000644000175000017500000000237614543456156015225 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Format::None; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { return { create_formatter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $formatter = sub { shift }; [$formatter]; }], }; } 1; # ABSTRACT: Perform no formatting on the message __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Format::None - Perform no formatting on the message =head1 VERSION version 0.042 =head1 SYNOPSIS use Log::ger::Format 'None'; =head1 DESCRIPTION =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head1 SEE ALSO L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Format/MultilevelLog.pm0000644000175000017500000001156314543456156017110 0ustar u1u1package Log::ger::Format::MultilevelLog; use strict; use warnings; use Log::ger::Util; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { my %conf = @_; my $sub_name = $conf{sub_name} || 'log'; my $method_name = $conf{method_name} || 'log'; return { create_filter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $filter = sub { my $level = Log::ger::Util::numeric_level(shift); return 0 unless $level <= $Log::ger::Current_Level; {level=>$level}; }; [$filter, 0, 'ml']; }, ], create_formatter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $formatter = # just like the default formatter, except it accepts first # argument (level) sub { shift; # level return $_[0] if @_ < 2; my $fmt = shift; my @args; for (@_) { if (!defined($_)) { push @args, ''; } elsif (ref $_) { push @args, Log::ger::Util::_dump($_); } else { push @args, $_; } } # redefine is just a dummy category for perls < 5.22 # which don't have 'redundant' yet no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine'); sprintf $fmt, @args; }; [$formatter, 0, 'ml']; }, ], create_routine_names => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" return [{ logger_subs => [[$sub_name , undef, 'ml', undef, 'ml']], logger_methods => [[$method_name, undef, 'ml', undef, 'ml']], }, $conf{exclusive}]; }, ], }; } 1; # ABSTRACT: Create a log($LEVEL, ...) subroutine/method __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Format::MultilevelLog - Create a log($LEVEL, ...) subroutine/method =head1 VERSION version 0.042 =head1 SYNOPSIS To use for the current package: use Log::ger::Format MultilevelLog => ( # sub_name => 'log_it', # optional, defaults to 'log' # method_name => 'log_it', # optional, defaults to 'log' # exclusive => 1, # optional, defaults to 0 ); use Log::ger; log('warn', 'This is a warning'); log('debug', 'This is a debug, data is %s', $data); log_warn "This is also a warning"; # still available, unless you set exclusive to 1 =head1 DESCRIPTION The Log::ger default is to create separate C subroutine (or C methods) for each level, e.g. C subroutine (or C method), C (or C), and so on. But sometimes you might want a log routine that takes $level as the first argument. That is, instead of: log_warn('blah ...'); or: $log->debug('Blah: %s', $data); you prefer: log('warn', 'blah ...'); or: $log->log('debug', 'Blah: %s', $data); This format plugin can create such log routine for you. Note: the multilevel log is slightly slower because of the extra argument and additional string level -> numeric level conversion. See benchmarks in L. Note: the individual separate C subroutines (or C methods) are still installed, unless you specify configuration L to true. =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head2 sub_name String. Defaults to C. =head2 method_name String. Defaults to C. =head2 exclusive Boolean. If set to true, will block the generation of the default C subroutines or C methods (e.g. C, C, ...). =head1 SEE ALSO L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Format/Default.pm0000644000175000017500000000620514543456156015705 0ustar u1u1package Log::ger::Format::Default; use strict; use warnings; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { my %conf = @_; return { create_formatter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $formatter = # the default formatter is sprintf-style that dumps data # structures arguments as well as undef as ''. sub { return $_[0] if @_ < 2; my $fmt = shift; my @args; for (@_) { if (!defined($_)) { push @args, ''; } elsif (ref $_) { require Log::ger::Util unless $Log::ger::_dumper; push @args, Log::ger::Util::_dump($_); } else { push @args, $_; } } # redefine is just a dummy category for perls < 5.22 which # don't have 'redundant' yet no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine'); sprintf $fmt, @args; }; [$formatter]; }], }; } 1; # ABSTRACT: Use default Log::ger formatting style __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Format::Default - Use default Log::ger formatting style =head1 VERSION version 0.042 =head1 SYNOPSIS use Log::ger::Format 'Default'; use Log::ger; log_debug "Printed as is"; # will format the log message as: Printed as is log_debug "Data for %s is %s", "budi", {foo=>'blah', bar=>undef}; # will format the log message as: Data for budi is {bar=>undef,foo=>"blah"} =head1 DESCRIPTION This is the default Log::ger formatter, which: 1) passes the argument as-is if there is only a single argument; or, if there are more than one argument, 2) treats the arguments like sprintf(), where the first argument is the template and the rest are variables to be substituted to the conversions inside the template. In the second case, reference arguments will be dumped using L or L by default (but the dumper is configurable by setting C<$Log::ger::_dumper>; see for example L or L). The same code is already included in L; this module just repackages it so it's more reusable. =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Layout.pm0000644000175000017500000000232514543456156014345 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Layout; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION use parent qw(Log::ger::Plugin); # we only use one layout, so set() should replace all hooks from previously set # plugin package sub _replace_package_regex { qr/\ALog::ger::Layout::/ } 1; # ABSTRACT: Use a layout plugin __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Layout - Use a layout plugin =head1 VERSION version 0.042 =head1 SYNOPSIS To set globally: use Log::ger::Layout; Log::ger::Layout->set('Pattern'); or: use Log::ger::Layout 'Pattern'; To set for current package only: use Log::ger::Layout; Log::ger::Layout->set_for_current_package('Pattern'); =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Util.pm0000644000175000017500000002546314543456156014015 0ustar u1u1package Log::ger::Util; use strict; use warnings; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION require Log::ger; require Log::ger::Heavy; sub _dump { unless ($Log::ger::_dumper) { eval { no warnings 'once'; require Data::Dmp; $Data::Dmp::OPT_REMOVE_PRAGMAS = 1; 1; }; if ($@) { no warnings 'once'; require Data::Dumper; $Log::ger::_dumper = sub { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Trailingcomma = 1; local $Data::Dumper::Useqq = 1; # to show "\034", possible bug in Data::Dumper Data::Dumper::Dumper($_[0]); }; } else { $Log::ger::_dumper = sub { Data::Dmp::dmp($_[0]) }; } } $Log::ger::_dumper->($_[0]); } sub numeric_level { my $level = shift; return $level if $level =~ /\A\d+\z/; return $Log::ger::Levels{$level} if defined $Log::ger::Levels{$level}; return $Log::ger::Level_Aliases{$level} if defined $Log::ger::Level_Aliases{$level}; die "Unknown level '$level'"; } sub string_level { my $level = shift; return $level if defined $Log::ger::Levels{$level}; $level = $Log::ger::Level_Aliases{$level} if defined $Log::ger::Level_Aliases{$level}; for (keys %Log::ger::Levels) { my $v = $Log::ger::Levels{$_}; return $_ if $v == $level; } die "Unknown level '$level'"; } sub set_level { no warnings 'once'; $Log::ger::Current_Level = numeric_level(shift); reinit_all_targets(); } sub _action_on_hooks { no warnings 'once'; my ($action, $target_type, $target_name, $phase) = splice @_, 0, 4; my $hooks = $Log::ger::Global_Hooks{$phase} or die "Unknown phase '$phase'"; if ($target_type eq 'package') { $hooks = ($Log::ger::Per_Package_Hooks{$target_name}{$phase} ||= []); } elsif ($target_type eq 'object') { my ($addr) = $target_name =~ $Log::ger::re_addr; $hooks = ($Log::ger::Per_Object_Hooks{$addr}{$phase} ||= []); } elsif ($target_type eq 'hash') { my ($addr) = $target_name =~ $Log::ger::re_addr; $hooks = ($Log::ger::Per_Hash_Hooks{$addr}{$phase} ||= []); } if ($action eq 'add') { my $hook = shift; # XXX remove duplicate key # my $key = $hook->[0]; unshift @$hooks, $hook; } elsif ($action eq 'remove') { my $code = shift; for my $i (reverse 0..$#{$hooks}) { splice @$hooks, $i, 1 if $code->($hooks->[$i]); } } elsif ($action eq 'reset') { my $saved = [@$hooks]; splice @$hooks, 0, scalar(@$hooks), @{ $Log::ger::Default_Hooks{$phase} }; return $saved; } elsif ($action eq 'empty') { my $saved = [@$hooks]; splice @$hooks, 0; return $saved; } elsif ($action eq 'save') { return [@$hooks]; } elsif ($action eq 'restore') { my $saved = shift; splice @$hooks, 0, scalar(@$hooks), @$saved; return $saved; } } sub add_hook { my ($phase, $hook) = @_; _action_on_hooks('add', '', undef, $phase, $hook); } sub add_per_target_hook { my ($target_type, $target_name, $phase, $hook) = @_; _action_on_hooks('add', $target_type, $target_name, $phase, $hook); } sub remove_hook { my ($phase, $code) = @_; _action_on_hooks('remove', '', undef, $phase, $code); } sub remove_per_target_hook { my ($target_type, $target_name, $phase, $code) = @_; _action_on_hooks('remove', $target_type, $target_name, $phase, $code); } sub reset_hooks { my ($phase) = @_; _action_on_hooks('reset', '', undef, $phase); } sub reset_per_target_hooks { my ($target_type, $target_name, $phase) = @_; _action_on_hooks('reset', $target_type, $target_name, $phase); } sub empty_hooks { my ($phase) = @_; _action_on_hooks('empty', '', undef, $phase); } sub empty_per_target_hooks { my ($target_type, $target_name, $phase) = @_; _action_on_hooks('empty', $target_type, $target_name, $phase); } sub save_hooks { my ($phase) = @_; _action_on_hooks('save', '', undef, $phase); } sub save_per_target_hooks { my ($target_type, $target_name, $phase) = @_; _action_on_hooks('save', $target_type, $target_name, $phase); } sub restore_hooks { my ($phase, $saved) = @_; _action_on_hooks('restore', '', undef, $phase, $saved); } sub restore_per_target_hooks { my ($target_type, $target_name, $phase, $saved) = @_; _action_on_hooks('restore', $target_type, $target_name, $phase, $saved); } sub reinit_target { my ($target_type, $target_name) = @_; # adds target if not already exists Log::ger::add_target($target_type, $target_name, {}, 0); if ($target_type eq 'package') { my $per_target_conf = $Log::ger::Package_Targets{$target_name}; Log::ger::init_target(package => $target_name, $per_target_conf); } elsif ($target_type eq 'object') { my ($obj_addr) = $target_name =~ $Log::ger::re_addr or die "Invalid object '$target_name': not a reference"; my $v = $Log::ger::Object_Targets{$obj_addr} or die "Unknown object target '$target_name'"; Log::ger::init_target(object => $v->[0], $v->[1]); } elsif ($target_type eq 'hash') { my ($hash_addr) = $target_name =~ $Log::ger::re_addr or die "Invalid hashref '$target_name': not a reference"; my $v = $Log::ger::Hash_Targets{$hash_addr} or die "Unknown hash target '$target_name'"; Log::ger::init_target(hash => $v->[0], $v->[1]); } else { die "Unknown target type '$target_type'"; } } sub reinit_all_targets { for my $pkg (keys %Log::ger::Package_Targets) { #print "D:reinit package $pkg\n"; Log::ger::init_target( package => $pkg, $Log::ger::Package_Targets{$pkg}); } for my $k (keys %Log::ger::Object_Targets) { my ($obj, $per_target_conf) = @{ $Log::ger::Object_Targets{$k} }; Log::ger::init_target(object => $obj, $per_target_conf); } for my $k (keys %Log::ger::Hash_Targets) { my ($hash, $per_target_conf) = @{ $Log::ger::Hash_Targets{$k} }; Log::ger::init_target(hash => $hash, $per_target_conf); } } sub set_plugin { my %args = @_; my $hooks; if ($args{hooks}) { $hooks = $args{hooks}; } else { no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict my $prefix = $args{prefix} || 'Log::ger::Plugin::'; my $mod = $args{name}; $mod = $prefix . $mod unless index($mod, $prefix) == 0; (my $mod_pm = "$mod.pm") =~ s!::!/!g; require $mod_pm; my $meta = $mod->can("meta") ? $mod->meta : {v=>1}; my $v = $meta->{v} || 1; # history of v bumping: # # - v increased from 1 to 2 in Log::ger v0.037 to force all plugins that # were not compatible with Log::ger 0.032 (removed # create_logml_routine phase) to be upgraded. unless ($v == 2) { die "Plugin '$mod' (version ".(${"$mod\::VERSION"} || "dev").")". " follows meta version $v but Log::ger (version ". (${__PACKAGE__."::VERSION"} || "dev"). ") (>0.032) requires meta version 2, ". "please upgrade the plugin first"; } $hooks = &{"$mod\::get_hooks"}(%{ $args{conf} || {} }); } { last unless $args{replace_package_regex}; my $all_hooks; if (!$args{target}) { $all_hooks = \%Log::ger::Global_Hooks; } elsif ($args{target} eq 'package') { $all_hooks = $Log::ger::Per_Package_Hooks{ $args{target_arg} }; } elsif ($args{target} eq 'object') { my ($addr) = $args{target_arg} =~ $Log::ger::re_addr; $all_hooks = $Log::ger::Per_Object_Hooks{$addr}; } elsif ($args{target} eq 'hash') { my ($addr) = $args{target_arg} =~ $Log::ger::re_addr; $all_hooks = $Log::ger::Per_Hash_Hooks{$addr}; } last unless $all_hooks; for my $phase (keys %$all_hooks) { my $hooks = $all_hooks->{$phase}; for my $i (reverse 0..$#{$hooks}) { splice @$hooks, $i, 1 if $hooks->[$i][0] =~ $args{replace_package_regex}; } } } for my $phase (keys %$hooks) { my $hook = $hooks->{$phase}; if (defined $args{target}) { add_per_target_hook( $args{target}, $args{target_arg}, $phase, $hook); } else { add_hook($phase, $hook); } } my $reinit = $args{reinit}; $reinit = 1 unless defined $reinit; if ($reinit) { if (defined $args{target}) { reinit_target($args{target}, $args{target_arg}); } else { reinit_all_targets(); } } } 1; # ABSTRACT: Utility routines for Log::ger __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Util - Utility routines for Log::ger =head1 VERSION version 0.042 =head1 DESCRIPTION This package is created to keep Log::ger as minimalist as possible. =head1 FUNCTIONS None of these functions are exported. =head2 numeric_level Usage: my $num = Log::ger::Util::numeric_level($level); If given a non-negative integer, will return the number as-is. Otherwise will convert the argument, assumed to be a string level, to the associated numeric level. Will die on failure. =head2 string_level Usage: my $str_level = Log::ger::Util::string_level($level); If given a known string level, will return the string as-is. Otherwise will convert the argument, assumed to be a number, to the associated string level. Will die on failure. =head2 set_level Usage: Log::ger::Util::set_level($level); Set log level to C<$level>, which can be a string or numeric level. Will die on failure. =head2 add_hook =head2 add_per_target_hook =head2 remove_hook =head2 remove_per_target_hook =head2 reset_hooks =head2 reset_per_target_hooks =head2 empty_hooks =head2 empty_per_target_hooks =head2 save_hooks =head2 save_per_target_hooks =head2 restore_hooks =head2 restore_per_target_hooks =head2 reinit_target =head2 reinit_all_targets =head2 set_plugin =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Output.pm0000644000175000017500000000251314543456156014367 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Output; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION use parent 'Log::ger::Plugin'; # we only use one output, so set() should replace all hooks from previously set # plugin package sub _replace_package_regex { qr/\ALog::ger::Output::/ } 1; # ABSTRACT: Set logging output __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Output - Set logging output =head1 VERSION version 0.042 =head1 SYNOPSIS To set globally: use Log::ger::Output; Log::ger::Output->set(Screen => ( use_color => 1, ... ); or: use Log::ger::Output 'Screen', ( use_color=>1, ... ); To set for current package only: use Log::ger::Output; Log::ger::Output->set_for_current_package(Screen => ( use_color => 1, ... ); =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Filter/0000775000175000017500000000000014543456156013757 5ustar u1u1Log-ger-0.042/lib/Log/ger/Filter/Code.pm0000644000175000017500000000247114543456156015171 0ustar u1u1package Log::ger::Filter::Code; use strict; use warnings; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 1, } } sub get_hooks { my %conf = @_; $conf{code} or die "Please specify code"; return { create_filter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" [$conf{code}]; }], }; } 1; # ABSTRACT: Filter using a coderef __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Filter::Code - Filter using a coderef =head1 VERSION version 0.042 =head1 SYNOPSIS use Log::ger::Filter Code => ( code => sub { ... }, ); =head1 DESCRIPTION Mainly for testing only. =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head2 code => coderef Required. =head1 SEE ALSO L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Heavy.pm0000644000175000017500000004264114543456156014151 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Heavy; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION #IFUNBUILT # use strict; # use warnings; #END IFUNBUILT package Log::ger; #IFUNBUILT # our ( # $re_addr, # %Levels, # %Level_Aliases, # $Current_Level, # $_outputter_is_null, # $_dumper, # %Global_Hooks, # %Package_Targets, # %Per_Package_Hooks, # %Hash_Targets, # %Per_Hash_Hooks, # %Object_Targets, # %Per_Object_Hooks, # ); #END IFUNBUILT # key = phase, value = [ [key, prio, coderef], ... ] our %Default_Hooks = ( create_filter => [], create_formatter => [ [__PACKAGE__, 90, sub { my %args = @_; # BEGIN_BLOCK: default_formatter my $formatter = # the default formatter is sprintf-style that dumps data # structures arguments as well as undef as ''. sub { return $_[0] if @_ < 2; my $fmt = shift; my @args; for (@_) { if (!defined($_)) { push @args, ''; } elsif (ref $_) { require Log::ger::Util unless $Log::ger::_dumper; push @args, Log::ger::Util::_dump($_); } else { push @args, $_; } } # redefine is just a dummy category for perls < 5.22 which # don't have 'redundant' yet no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine'); sprintf $fmt, @args; }; [$formatter]; # END_BLOCK: default_formatter }], ], create_layouter => [], create_routine_names => [ [__PACKAGE__, 90, # the default names are log_LEVEL() and log_is_LEVEL() for subroutine # names, or LEVEL() and is_LEVEL() for method names sub { my %args = @_; my $levels = [keys %Levels]; return [{ logger_subs => [map { ["log_$_", $_] } @$levels], level_checker_subs => [map { ["log_is_$_", $_] } @$levels], # used when installing to hash or object logger_methods => [map { ["$_", $_] } @$levels], level_checker_methods => [map { ["is_$_", $_] } @$levels], }, 1]; }], ], # old name for create_outputter, deprecated and will be removed in the # future create_log_routine => [], create_outputter => [ [__PACKAGE__, 10, # the default behavior is to create a null routine for levels that are # too high than the global level ($Current_Level). since we run at high # priority (10), we block typical output plugins at normal priority # (50). this is a convenience so normally a plugin does not have to # deal with level checking. plugins that want to do its own level # checking can use a higher priority. sub { my %args = @_; my $level = $args{level}; my $num_outputs = 0; $num_outputs += @{ $Global_Hooks{create_log_routine} }; # old name, will be removed $num_outputs += @{ $Global_Hooks{create_outputter} }; if ( # level indicates routine should be a null logger (defined $level && $Current_Level < $level) || # there's only us that produces log routines (e.g. no outputs) $num_outputs == 1 ) { $_outputter_is_null = 1; return [sub {0}]; } [undef]; # decline, let output plugin supply logger routines }], ], # old name for create_level_checker, deprecated and will be removed in the # future create_is_routine => [], create_level_checker => [ [__PACKAGE__, 90, # the default behavior is to compare to global level. normally this # behavior suffices. we run at low priority (90) so normal plugins # which typically use priority 50 can override us. sub { my %args = @_; my $level = $args{level}; [sub { $Current_Level >= $level }]; }], ], before_install_routines => [], after_install_routines => [], ); for my $phase (keys %Default_Hooks) { $Global_Hooks{$phase} = [@{ $Default_Hooks{$phase} }]; } # if flow_control is 1, stops after the first hook that gives non-undef result. # flow_control can also be a coderef that will be called after each hook with # ($hook, $hook_res) and can return 1 to mean stop. sub run_hooks { my ($phase, $hook_args, $flow_control, $target_type, $target_name) = @_; #print "D: running hooks for phase $phase\n"; $Global_Hooks{$phase} or die "Unknown phase '$phase'"; my @hooks = @{ $Global_Hooks{$phase} }; if ($target_type eq 'package') { unshift @hooks, @{ $Per_Package_Hooks{$target_name}{$phase} || [] }; } elsif ($target_type eq 'hash') { my ($addr) = "$target_name" =~ $re_addr; unshift @hooks, @{ $Per_Hash_Hooks{$addr}{$phase} || [] }; } elsif ($target_type eq 'object') { my ($addr) = "$target_name" =~ $re_addr; unshift @hooks, @{ $Per_Object_Hooks{$addr}{$phase} || [] }; } my $res; for my $hook (sort {$a->[1] <=> $b->[1]} @hooks) { my $hook_res = $hook->[2]->(%$hook_args); if (defined $hook_res->[0]) { $res = $hook_res->[0]; #print "D: got result from hook $hook->[0]: $res\n"; if (ref $flow_control eq 'CODE') { last if $flow_control->($hook, $hook_res); } else { last if $flow_control; } } last if $hook_res->[1]; } return $res; } sub init_target { my ($target_type, $target_name, $per_target_conf) = @_; #print "D:init_target($target_type, $target_name, ...)\n"; my %hook_args = ( target_type => $target_type, target_name => $target_name, per_target_conf => $per_target_conf, ); # collect only a single filter my %filters; run_hooks( 'create_filter', \%hook_args, # collect filters, until a hook instructs to stop sub { my ($hook, $hook_res) = @_; my ($filter, $flow_control, $fltname) = @$hook_res; $fltname = 'default' if !defined($fltname); $filters{$fltname} ||= $filter; $flow_control; }, $target_type, $target_name); my %formatters; run_hooks( 'create_formatter', \%hook_args, # collect formatters, until a hook instructs to stop sub { my ($hook, $hook_res) = @_; my ($formatter, $flow_control, $fmtname) = @$hook_res; $fmtname = 'default' if !defined($fmtname); $formatters{$fmtname} ||= $formatter; $flow_control; }, $target_type, $target_name); # collect only a single layouter my $layouter = run_hooks( 'create_layouter', \%hook_args, 1, $target_type, $target_name); my $routine_names = {}; run_hooks( 'create_routine_names', \%hook_args, # collect routine names, until a hook instructs to stop. sub { my ($hook, $hook_res) = @_; my ($routine_name_rec, $flow_control) = @$hook_res; $routine_name_rec or return; for (keys %$routine_name_rec) { push @{ $routine_names->{$_} }, @{ $routine_name_rec->{$_} }; } $flow_control; }, $target_type, $target_name); my @routines; my $is_object = $target_type eq 'object'; CREATE_LOGGER_ROUTINES: { my @routine_name_recs; if ($target_type eq 'package') { push @routine_name_recs, @{ $routine_names->{log_subs} || [] }; # old name, will be removed push @routine_name_recs, @{ $routine_names->{logger_subs} || [] }; } else { push @routine_name_recs, @{ $routine_names->{log_methods} || [] }; # old name, will be removed push @routine_name_recs, @{ $routine_names->{logger_methods} || [] }; } NAME: for my $routine_name_rec (@routine_name_recs) { my ($rname, $lname, $fmtname, $rper_target_conf, $fltname) = @$routine_name_rec; my $lnum; $lnum = $Levels{$lname} if defined $lname; $fmtname = 'default' if !defined($fmtname); my ($output_routine, $logger); $_outputter_is_null = 0; local $hook_args{name} = $rname; # compat, deprecated local $hook_args{routine_name} = $rname; local $hook_args{level} = $lnum; local $hook_args{str_level} = $lname; my $outputter; { $outputter = run_hooks("create_outputter" , \%hook_args, 1, $target_type, $target_name) and last; $outputter = run_hooks("create_log_routine", \%hook_args, 1, $target_type, $target_name); # old name, will be removed in the future } die "BUG in configuration: No outputter is produced for routine name $rname" unless $outputter; { # enclosing block if ($_outputter_is_null) { # if outputter is a null outputter (sub {0}) we don't need # to format message, layout message, or care about the # logger routine being a subroutine/object. shortcut here # for faster init. $logger = $outputter; last; } my $formatter = $formatters{$fmtname}; my $filter = defined($fltname) ? $filters{$fltname} : undef; # zoom out to see vertical alignments... we have filter(x2) x # formatter+layouter(x3) x OO/non-OO (x2) = 12 permutations. we # create specialized subroutines for each case, for performance # reason. if ($filter) { if ($formatter) { if ($layouter) { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname, $per_msg_conf), $per_msg_conf) }; # has-filter has-formatter has-layouter with-oo } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname, $per_msg_conf), $per_msg_conf) }; } # has-filter has-formatter has-layouter not-oo } else { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_), $per_msg_conf) }; # has-filter has-formatter no-layouter with-oo } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_), $per_msg_conf) }; } } # has-filter has-formatter no-layouter not-oo } else { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, \@_, $per_msg_conf) }; # has-filter no-formatter no-layouter with-oo } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, \@_, $per_msg_conf) }; } } # has-filter no-formatter no-layouter not-oo } else { if ($formatter) { if ($layouter) { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname ) ) }; # no-filter has-formatter has-layouter with-oo } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname ) ) }; } # no-filter has-formatter has-layouter not-oo } else { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_) ) }; # no-filter has-formatter no-layouter with-oo } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_) ) }; } } # no-filter has-formatter no-layouter not-oo } else { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, \@_ ) }; # no-filter no-formatter no-layouter with-oo } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, \@_ ) }; } } } # no-filter no-formatter no-layouter not-oo } # enclosing block L1: my $rtype = $is_object ? 'logger_method' : 'logger_sub'; push @routines, [$logger, $rname, $lnum, $rtype, $rper_target_conf||$per_target_conf]; } } CREATE_LEVEL_CHECKER_ROUTINES: { my @routine_name_recs; my $type; if ($target_type eq 'package') { push @routine_name_recs, @{ $routine_names->{is_subs} || [] }; # old name, will be removed push @routine_name_recs, @{ $routine_names->{level_checker_subs} || [] }; $type = 'level_checker_sub'; } else { push @routine_name_recs, @{ $routine_names->{is_methods} || [] }; # old name, will be removed push @routine_name_recs, @{ $routine_names->{level_checker_methods} || [] }; $type = 'level_checker_method'; } for my $routine_name_rec (@routine_name_recs) { my ($rname, $lname) = @$routine_name_rec; my $lnum = $Levels{$lname}; local $hook_args{name} = $rname; local $hook_args{level} = $lnum; local $hook_args{str_level} = $lname; my $code_is; { $code_is = run_hooks('create_is_routine' , \%hook_args, 1, $target_type, $target_name) and last; # old name, will be removed $code_is = run_hooks('create_level_checker', \%hook_args, 1, $target_type, $target_name); } die "BUG in configuration: No level_checker routine is produced for routine name $rname" unless $code_is; push @routines, [$code_is, $rname, $lnum, $type, $per_target_conf]; } } { local $hook_args{routines} = \@routines; local $hook_args{filters} = \%filters; local $hook_args{formatters} = \%formatters; local $hook_args{layouter} = $layouter; run_hooks('before_install_routines', \%hook_args, 0, $target_type, $target_name); } install_routines($target_type, $target_name, \@routines, 1); { local $hook_args{routines} = \@routines; run_hooks('after_install_routines', \%hook_args, 0, $target_type, $target_name); } } 1; # ABSTRACT: The bulk of the implementation of Log::ger __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Heavy - The bulk of the implementation of Log::ger =head1 VERSION version 0.042 =head1 DESCRIPTION This module contains the bulk of the implementation of Log::ger, to keep Log::ger superslim. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Plugin.pm0000644000175000017500000000363314543456156014331 0ustar u1u1package Log::ger::Plugin; use strict; use warnings; use Log::ger::Util; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub set { my $pkg = shift; my %args; if (ref $_[0] eq 'HASH') { %args = %{shift()}; } else { %args = (name => shift, conf => {@_}); } $args{prefix} ||= $pkg . '::'; $args{replace_package_regex} = $pkg->_replace_package_regex; Log::ger::Util::set_plugin(%args); } sub set_for_current_package { my $pkg = shift; my %args; if (ref $_[0] eq 'HASH') { %args = %{shift()}; } else { %args = (name => shift, conf => {@_}); } my $caller = caller(0); $args{target} = 'package'; $args{target_arg} = $caller; set($pkg, \%args); } sub _import_sets_for_current_package { 0 } sub _replace_package_regex { undef } sub import { if (@_ > 1) { if ($_[0]->_import_sets_for_current_package) { goto &set_for_current_package; } else { goto &set; } } } 1; # ABSTRACT: Use a plugin __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Plugin - Use a plugin =head1 VERSION version 0.042 =head1 SYNOPSIS To set globally: use Log::ger::Plugin; Log::ger::Plugin->set('OptAway'); or: use Log::ger::Plugin 'OptAway'; To set for current package only: use Log::ger::Plugin; Log::ger::Plugin->set_for_current_package('OptAway'); =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Format.pm0000644000175000017500000000242014543456156014314 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Format; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION use parent qw(Log::ger::Plugin); sub _import_sets_for_current_package { 1 } 1; # ABSTRACT: Use a format plugin __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Format - Use a format plugin =head1 VERSION version 0.042 =head1 SYNOPSIS To set for current package only: use Log::ger::Format 'Block'; or: use Log::ger::Format; Log::ger::Format->set_for_current_package('Block'); To set globally: use Log::ger::Format; Log::ger::Format->set('Block'); =head1 DESCRIPTION Note: Since format plugins affect log-producing code, the import syntax defaults to setting for current package instead of globally. =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Filter.pm0000644000175000017500000000220714543456156014314 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Filter; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION use parent qw(Log::ger::Plugin); 1; # ABSTRACT: Use a filter plugin __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Filter - Use a filter plugin =head1 VERSION version 0.042 =head1 SYNOPSIS To set globally: use Log::ger::Filter; Log::ger::Filter->set('Code', code => sub{ ... }); or: use Log::ger::Filter 'Code', (code => sub { ... }); To set for current package only: use Log::ger::Filter; Log::ger::Filter->set_for_current_package('Code', code => sub { ... }); =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L L L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Output/0000775000175000017500000000000014543456156014032 5ustar u1u1Log-ger-0.042/lib/Log/ger/Output/String.pm0000644000175000017500000000426314543456156015641 0ustar u1u1package Log::ger::Output::String; use strict; use warnings; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { my %plugin_conf = @_; $plugin_conf{string} or die "Please specify string"; my $formatter = $plugin_conf{formatter}; my $append_newline = $plugin_conf{append_newline}; $append_newline = 1 unless defined $append_newline; return { create_outputter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $level = $hook_args{level}; my $outputter = sub { my ($per_target_conf, $msg, $per_msg_conf) = @_; if ($formatter) { $msg = $formatter->($msg); } ${ $plugin_conf{string} } .= $msg; ${ $plugin_conf{string} } .= "\n" unless !$append_newline || $msg =~ /\R\z/; }; [$outputter]; }], }; } 1; # ABSTRACT: Set output to a string __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Output::String - Set output to a string =head1 VERSION version 0.042 =head1 SYNOPSIS BEGIN { our $str } use Log::ger::Output 'String' => ( string => \$str, # append_newline => 0, # default is true, to mimic Log::ger::Output::Screen ); use Log::ger; log_warn "warn ..."; log_error "debug ..."; C<$str> will contain "warn ...\n". =head1 DESCRIPTION For testing only. =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head2 string => scalarref Required. =head2 formatter => coderef Optional. =head2 append_newline => bool (default: 1) =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Output/Array.pm0000644000175000017500000000276314543456156015454 0ustar u1u1package Log::ger::Output::Array; use strict; use warnings; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { my %plugin_conf = @_; $plugin_conf{array} or die "Please specify array"; return { create_outputter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $outputter = sub { my ($per_target_conf, $msg, $per_msg_conf) = @_; push @{$plugin_conf{array}}, $msg; }; [$outputter]; }], }; } 1; # ABSTRACT: Log to array __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Output::Array - Log to array =head1 VERSION version 0.042 =head1 SYNOPSIS use Log::ger::Output Array => ( array => $ary, ); =head1 DESCRIPTION Mainly for testing only. =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head2 array => arrayref Required. =head1 SEE ALSO L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Output/Null.pm0000644000175000017500000000240114543456156015275 0ustar u1u1## no critic: TestingAndDebugging::RequireUseStrict package Log::ger::Output::Null; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { return { create_outputter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" $Log::ger::_outputter_is_null = 1; my $outputter = sub {0}; [$outputter]; }], }; } 1; # ABSTRACT: Null output __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Output::Null - Null output =head1 VERSION version 0.042 =head1 SYNOPSIS use Log::ger; use Log::ger::Output 'Null'; log_warn "blah..."; =head1 DESCRIPTION =for Pod::Coverage ^(.+)$ =head1 CONFIGURATION =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/lib/Log/ger/Plugin/0000775000175000017500000000000014543456156013770 5ustar u1u1Log-ger-0.042/lib/Log/ger/Plugin/MultilevelLog.pm0000644000175000017500000000717314543456156017120 0ustar u1u1package Log::ger::Plugin::MultilevelLog; use strict; use warnings; use Log::ger::Util; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2023-12-29'; # DATE our $DIST = 'Log-ger'; # DIST our $VERSION = '0.042'; # VERSION sub meta { +{ v => 2, } } sub get_hooks { my %conf = @_; my $sub_name = $conf{sub_name} || 'log'; my $method_name = $conf{method_name} || 'log'; return { create_filter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $filter = sub { my $level = Log::ger::Util::numeric_level(shift); return 0 unless $level <= $Log::ger::Current_Level; {level=>$level}; }; [$filter, 0, 'ml']; }, ], create_formatter => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" my $formatter = # just like the default formatter, except it accepts first # argument (level) sub { shift; # level return $_[0] if @_ < 2; my $fmt = shift; my @args; for (@_) { if (!defined($_)) { push @args, ''; } elsif (ref $_) { push @args, Log::ger::Util::_dump($_); } else { push @args, $_; } } # redefine is just a dummy category for perls < 5.22 # which don't have 'redundant' yet no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine'); sprintf $fmt, @args; }; [$formatter, 0, 'ml']; }, ], create_routine_names => [ __PACKAGE__, # key 50, # priority sub { # hook my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" return [{ logger_subs => [[$sub_name , undef, 'ml', undef, 'ml']], logger_methods => [[$method_name, undef, 'ml', undef, 'ml']], }, $conf{exclusive}]; }, ], }; } 1; # ABSTRACT: (DEPRECATED) Old name for Log::ger::Format::MultilevelLog __END__ =pod =encoding UTF-8 =head1 NAME Log::ger::Plugin::MultilevelLog - (DEPRECATED) Old name for Log::ger::Format::MultilevelLog =head1 VERSION version 0.042 =head1 DESCRIPTION This plugin has been renamed to L in 0.038. The old name is provided for backward compatibility for now, but is deprecated and will be removed in the future. Please switch to the new name and be aware that format plugins only affect the current package. =for Pod::Coverage ^(.+)$ =head1 SEE ALSO L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-ger-0.042/README0000644000175000017500000001536014543456156011351 0ustar u1u1NAME Log::ger - A lightweight, flexible logging framework VERSION version 0.042 SYNOPSIS Producing logs In your module (producer): package MyModule; # this will install some logger routines. by default: log_trace, log_debug, # log_info, log_warn, log_error, and log_fatal. level checker routines are also # installed: log_is_trace, log_is_debug, and so on. use Log::ger; sub foo { ... # produce some logs. no need to configure output or level. by default # output goes nowhere. log_error "an error occured: %03d - %s", $errcode, $errmsg; ... # the logging routines (log_*) can automatically dump data structures log_debug "http response: %s", $http; # log_fatal does not die by default, if you want to then die() explicitly. # but there are plugins that let you do this or provide log_die etc. if (blah) { log_fatal "..."; die } # use the level checker routines (log_is_*) to avoid doing unnecessary # heavy calculation if (log_is_trace) { my $res = some_heavy_calculation(); log_trace "The result is %s", $res; } } 1; Consuming logs Choosing an output In your application (consumer/listener): use MyModule; use Log::ger::Output 'Screen'; # configure output # level is by default 'warn' foo(); # the error message is shown, but debug/trace messages are not. Choosing multiple outputs Instead of screen, you can output to multiple outputs (including multiple files): use Log::ger::Output 'Composite' => ( outputs => { Screen => {}, File => [ {conf=>{path=>'/path/to/app.log'}}, ... ], ... }, ); See Log::ger::Manual::Tutorial::481_Output_Composite for more examples. There is also Log::ger::App that wraps this in a simple interface so you just need to do: # In your application or script: use Log::ger::App; use MyModule; Choosing level One way to set level: use Log::ger::Util; Log::ger::Util::set_level('debug'); # be more verbose foo(); # the error message as well as debug message are now shown, but the trace is not There are better ways, e.g. letting users configure log level via configuration file or command-line option. See Log::ger::Manual::Tutorial::300_Level for more details. DESCRIPTION Log::ger is yet another logging framework with the following features: * Separation of producers and consumers/listeners Like Log::Any, this offers a very easy way for modules to produce some logs without having to configure anything. Configuring output, level, etc can be done in the application as log consumers/listeners. To read more about this, see the documentation of Log::Any or Log::ger::Manual (but nevertheless see Log::ger::Manual on why you might prefer Log::ger to Log::Any). * Lightweight and fast Slim distribution. No non-core dependencies, extra functionalities are provided in separate distributions to be pulled as needed. Low startup overhead. Only ~0.5-1ms. For comparison, strict ~0.2-0.5ms, warnings ~2ms, Log::Any (v0.15) ~2-3ms, Log::Any (v1.049) ~8-10ms, Log::Log4perl ~35ms. This is measured on a 2014-2015 PC and before doing any output configuration. I strive to make "use Log::ger;" statement to be roughly as light as "use strict;" or "use warnings;" so the impact of adding the statement is really minimal and you can just add logging without much thought to most of your modules. This is important to me because I want logging to be pervasive. To test for yourself, try e.g. with bencher-code: % bencher-code 'use Log::ger' 'use Log::Any' --startup Fast. Low null-/stealth-logging overhead, about 1.5x faster than Log::Any, 3x faster than Log4perl, 5x faster than Log::Fast, ~40x faster than Log::Contextual, and ~100x faster than Log::Dispatch. For more benchmarks, see Bencher::Scenarios::Log::ger. Conditional compilation. There is a plugin to optimize away unneeded logging statements, like assertion/conditional compilation, so they have zero runtime performance cost. See Log::ger::Plugin::OptAway. Being lightweight means the module can be used more universally, from CLI to long-running daemons to inside routines with tight loops. * Flexible Customizable levels and routine/method names. Can be used in a procedural or OO style. Log::ger can mimic the interface of Log::Any, Log::Contextual, Log::Log4perl, or some other popular logging frameworks, to ease migration or adjust with your personal style. Per-package settings. Each importer package can use its own format/layout, output. For example, a module that is migrated from Log::Any uses Log::Any-style logging, while another uses native Log::ger style, and yet some other uses block formatting like Log::Contextual. This eases code migration and teamwork. Each module author can preserve her own logging style, if wanted, and all the modules still use the same framework. Dynamic. Outputs and levels can be changed anytime during run-time and logger routines will be updated automatically. This is useful in situation like a long-running server application: you can turn on tracing logs temporarily to debug problems, then turn them off again, without restarting your server. Interoperability. There are modules to interop with Log::Any, either consume Log::Any logs (see Log::Any::Adapter::LogGer) or produce logs to be consumed by Log::Any (see Log::ger::Output::LogAny). Many output modules and plugins. See "Log::ger::Output::*", "Log::ger::Format::*", "Log::ger::Layout::*", "Log::ger::Plugin::*". Writing an output module in Log::ger is easier than writing a Log::Any::Adapter::*. For more documentation, start with Log::ger::Manual. SEE ALSO Some other popular logging frameworks: Log::Any, Log::Contextual, Log::Log4perl, Log::Dispatch, Log::Dispatchouli. If you still prefer debugging using the good old print(), there's Debug::Print. AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Log-ger-0.042/Changes0000644000175000017500000002440614543456156011765 0ustar u1u10.042 2023-12-29 Released-By: PERLANCAR; Urgency: low - No functional changes. - Document functions in Log::ger::Util. 0.041 2023-10-29 Released-By: PERLANCAR; Urgency: low - No functional changes. - [doc] Fix minor typos, update mentioned module name. 0.040 2022-06-10 Released-By: PERLANCAR; Urgency: low - No functional changes. - Edit Changes to add Backward-Incompatible metadata. 0.039 2022-06-10 Released-By: PERLANCAR; Urgency: low - No functional changes. - [doc] Tweak Log::ger's Synopsis to make the code more explanatory. - [internals] Replace 'use var' with 'our' as the former is discouraged in 5.006+ (thanks James Raspass). 0.038 2021-01-31 Released-By: PERLANCAR; Urgency: medium - Rename Log::ger::Plugin::MultilevelLog to the more appropriate Log::ger::Format::MultilevelLog, so use-ing it affects the current package only. The old name is still available but deprecated and will be removed in the future. 0.037 2020-03-11 Released-By: PERLANCAR; Urgency: high; Backward-Incompatible: yes - [Incompatible change] Bump meta version to 2 to force all plugins to be upgraded to comply to Log::ger >0.032. 0.036 2020-03-10 Released-By: PERLANCAR; Urgency: medium - Add _import_to() to easily import to an arbitrary package. 0.035 2020-03-10 Released-By: PERLANCAR; Urgency: medium - Support perl < 5.22 (no warnings category 'redundant' yet) [RT#132066]. 0.034 2020-03-09 Released-By: PERLANCAR; Urgency: medium - Add meta() and check meta version so in the future we can reject plugins that are not up-to-date. 0.033 2020-03-07 Released-By: PERLANCAR; Urgency: medium - Rename things for clarity. 1) routine types: log_{sub,method} -> logger_{sub,method}, is_{sub,method} -> level_checker_{sub,method} (old names still accepted for now). 2) hooks: create_is_routine -> create_level_checker, create_log_routine -> create_outputter (old names still accepted for now). This avoids confusion between "logger routine" (the final routine that gets installed to target) vs "outputter" (the routine that does actual sending to output, provided by output plugins). The "is routine" was also a bad name. 0.032 2020-03-06 Released-By: PERLANCAR; Urgency: medium; Backward-Incompatible: yes - Introduce filters as a way to do custom filtering as well as to extract additional information from the original logger arguments, e.g. so we can do multilevel log(level=>..., message=>...), pass category log(category=>..., ...) and so on. - [INCOMPATIBLE CHANGE] [removed feature] Remove multilevel (logml) stuffs and reimplement them with filters: remove logml_{subs,methods} routine types, remove create_logml_routine phase, remove ArrayML output. All outputs/plugins that provide create_logml_routine will stop working and will need to be updated. - [INCOMPATIBLE CHANGE] Rename some hook arguments passed to plugin for clarity: target -> target_type, target_arg -> target_name, init_args -> per_target_conf. - Merge Log::ger::Format::Default from Log-ger-Default-Format. - Rename variables/terminologies to be clearer: target -> target type, target arg -> target name, init args -> per-target conf. We also now have per-message conf, produced by filter. 0.031 2020-03-04 Released-By: PERLANCAR; Urgency: medium - Allow each routine to have its own init args; this allows e.g. creating multiple sets of logger subroutines that log to different categories, as implemented in Log::ger::Plugin::Multisets. - Silence 'Redundant argument in sprintf' warning. - [doc] Tweak to make module name and version clearer [GH #2]. 0.030 2020-02-18 Released-By: PERLANCAR; Urgency: low - No functional changes. - [doc] Tweak Synopsis, at least show how to set level & pick multiple outputs. 0.029 2020-02-18 Released-By: PERLANCAR; Urgency: low - No functional changes. - [dist] Mark default formatter block using # BEGIN_BLOCK .. # END_BLOCK so it can be extracted by Dist::Zilla plugin [InsertBlock::FromModule]. 0.028 2019-05-06 Released-By: PERLANCAR - Use Data::Dumper's Useqq=1 to show unprintable characters. 0.027 2019-04-13 Released-By: PERLANCAR - Fix startup overhead regression by avoiding to load Sub::Name & name routines if we don't have any outputs. 0.026 2019-04-12 Released-By: PERLANCAR - UPDATE 2019-04-13: This version has startup overhead regression. You might want to update to 0.027. - Name the generated routines with Sub::Name if available. - Remove declaration of unneeded variable $Caller_Depth_Offset. 0.025 2018-12-20 Released-By: PERLANCAR - No functional changes. - [doc] Mention Debug::Print. - [doc] Also mention speed relative to Log::Contextual. 0.024 2018-12-20 Released-By: PERLANCAR - No functional changes. - [doc] Mention that Log::ger is ~100x faster than Log::Dispatch. 0.023 2017-08-03 Released-By: PERLANCAR - [Internal] Change the numeric values of level, to accomodate more room for custom levels. - Defer set default null routines so other module can customize levels. 0.022 2017-08-03 Released-By: PERLANCAR - [Bugfix] Fix stupid copy-paste mistake [RT#122687]. - [doc] Fix copy-paste mistake [RT#122689]. 0.021 2017-08-02 Released-By: PERLANCAR - [Bugfix] Output, Layout: set() now properly replaces hooks from previous output/layout plugin (need to remove from all phases). - Add output for testing: ArrayML. 0.020 2017-07-30 Released-By: PERLANCAR - [ux] Enable $Data::Dmp::OPT_REMOVE_PRAGMAS. 0.019 2017-07-14 Released-By: PERLANCAR - [Bugfix] Forgot to create preconstructed default null-loggers for object target. 0.018 2017-07-14 Released-By: PERLANCAR - 'use Log::ger::Format "Foo"' now sets for current package instead of globally (but the other plugins like Log::ger::Output or Log::ger::Layout still defaults to setting globally). 0.017 2017-07-13 Released-By: PERLANCAR - No functional changes. - [doc] Update some benchmark numbers. 0.016 2017-07-13 Released-By: PERLANCAR - Reduce startup overhead by splitting some parts of Log::ger to Log::ger::Heavy. When user loads modules that have 'use Log::ger', but never adds any outputs (which is a pretty common case when user just uses a module without setting up any logging), then we can cheat by skipping init_target() and just installs the null, default-named logging routines. So we split the part that does real init_target() to Log::ger::Heavy, similar to how Carp & Carp::Heavy was split. This reduces startup overhead significantly. When user loads Log::ger::Util (e.g. to run set_plugin()) or when some hooks are added, then we load Log::ger::Heavy. 0.015 2017-07-12 Released-By: PERLANCAR - [Bugfix] Used the wrong key to get per-object hooks. 0.014 2017-07-11 Released-By: PERLANCAR - Pass 'formatters' and 'layouter' arguments to before_install_routines hook. 0.013 2017-07-11 Released-By: PERLANCAR - Allow multiple formatters. 0.012 2017-07-02 Released-By: PERLANCAR - [optimize] init_target: Reuse multilevel log routine from hook for log routines of all levels. - [Bugfix] Fix string level passed to layouter when logger is a multilevel logger. 0.011 2017-06-30 Released-By: PERLANCAR; Backward-Incompatible: yes - [Incompatible change] In hook argument "routines", change $flags to $type to be more general. The value can be 'log_sub', 'log_method', 'logml_sub', 'logml_method', 'is_sub', 'is_method'. - Support multilevel log statement log($level, ...) by using LGP:MultilevelLog (included in core distribution). - [Internal] Introduce phase 'create_logml_routine'. - [Test] Add test for LG:Format::None. - [Bugfix] reinit_target() didn't find the correct hash key. 0.010 2017-06-28 Released-By: PERLANCAR - [Bugfix] Don't install log methods to package (vice versa, don't install log subroutines to object package). - [doc] Remove mention of filter. 0.009 2017-06-28 Released-By: PERLANCAR - Remove Log::ger::Filter and 'create_filter' phase because they are unused. - Add Layout. - Add formatter: None. 0.008 2017-06-26 Released-By: PERLANCAR - Util: Add string_level(). 0.007 2017-06-25 Released-By: PERLANCAR - Add custom level test. - Add output: Array. 0.006 2017-06-24 Released-By: PERLANCAR - [Bugfix] Use the correct package when initializing object. 0.005 2017-06-23 Released-By: PERLANCAR; Backward-Incompatible: yes - [Incompatible change] Another round of internal refactoring and interface changes. New: Log::ger::{Plugin,Format,Filter}. Every plugin (including filter, format, output) can be set on a per-target basis or globally. The term 'hooks' is in again. Add 'create_routine_names' phase. Remove 'after_create_log_routine', 'after_create_log_is_routine'. Move FAQ & internals doc to Log-ger-Manual dist. 0.004 2017-06-21 Released-By: PERLANCAR - [Bugfix] Log::ger::Output didn't have VERSION. 0.003 2017-06-21 Released-By: PERLANCAR - Split Log::ger::Output::Screen to its own dist so this dist can be more minimalist and that module can be tested e.g. with Capture::Tiny etc. - String output: add option append_newline to allow disable appending newline. - import(): No need to turn category 'Foo::Bar' -> 'foo.bar'. - [doc] Update module name Log::ger::LogAny -> Log::ger::Output::LogAny. 0.002 2017-06-21 Released-By: PERLANCAR; Backward-Incompatible: yes - [Incompatible change] Reorganize internals & fix a couple of doc typos. - Add outputs: Null, String (mainly for testing). - Formatter: format undef as '' like in Log::Any. - Screen output: Add hooks for Progress::Any::Output::TermProgressBarColor, like in Log::Any::Adapter::Screen. - Add some tests. 0.001 2017-06-19 Released-By: PERLANCAR - First release. Log-ger-0.042/MANIFEST0000644000175000017500000000137714543456156011625 0ustar u1u1# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.031. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Log/ger.pm lib/Log/ger/Filter.pm lib/Log/ger/Filter/Code.pm lib/Log/ger/Format.pm lib/Log/ger/Format/Default.pm lib/Log/ger/Format/MultilevelLog.pm lib/Log/ger/Format/None.pm lib/Log/ger/Heavy.pm lib/Log/ger/Layout.pm lib/Log/ger/Output.pm lib/Log/ger/Output/Array.pm lib/Log/ger/Output/Null.pm lib/Log/ger/Output/String.pm lib/Log/ger/Plugin.pm lib/Log/ger/Plugin/MultilevelLog.pm lib/Log/ger/Util.pm t/00-compile.t t/01-basic.t t/author-critic.t t/author-pod-coverage.t t/author-pod-syntax.t t/format-none.t t/level.t t/no-format.t t/output-array.t t/output-null.t t/output-string.t t/plugin-multilevellog.t