GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Log::ger::Format::MultilevelLog(3) User Contributed Perl Documentation Log::ger::Format::MultilevelLog(3)

Log::ger::Format::MultilevelLog - Create a log($LEVEL, ...) subroutine/method

version 0.038

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

The Log::ger default is to create separate "log_LEVEL" subroutine (or "LEVEL" methods) for each level, e.g. "log_trace" subroutine (or "trace" method), "log_warn" (or "warn"), 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 Bencher::Scenarios::LogGer.

Note: the individual separate "log_LEVEL" subroutines (or "LEVEL" methods) are still installed, unless you specify configuration "exclusive" to true.

String. Defaults to "log".

String. Defaults to "log".

Boolean. If set to true, will block the generation of the default "log_LEVEL" subroutines or "LEVEL" methods (e.g. "log_warn", "trace", ...).

Log::ger::Format::HashArgs

perlancar <perlancar@cpan.org>

This software is copyright (c) 2021, 2020, 2019, 2018, 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2021-01-31 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.