|
NAMELog::Report::Domain - administer one text-domainINHERITANCELog::Report::Domain is a Log::Report::Minimal::Domain Log::Report::Domain is extended by Log::Report::Template::Textdomain SYNOPSIS# internal usage use Log::Report::Domain; my $domain = Log::Report::Domain->new(name => $name); # find a ::Domain object use Log::Report 'my-domain'; my $domain = textdomain 'my-domain'; # find domain config my $domain = textdomain; # config of this package # explicit domain configuration package My::Package; use Log::Report 'my-domain'; # set textdomain for package textdomain $name, %configure; # set config, once per program (textdomain $name)->configure(%configure); # same textdomain->configure(%configure); # same if current package in $name # implicit domain configuration package My::Package; use Log::Report 'my-domain', %configure; # external file for configuration (perl or json format) use Log::Report 'my-domain', config => $filename; use Log::Report 'my-domain'; textdomain->configure(config => $filename); DESCRIPTIONLog::Report can handle multiple sets of packages at the same time: in the usual case a program consists of more than one software distribution, each containing a number of packages. Each module in an application belongs to one of these sets, by default the domain set 'default'.For "Log::Report", those packags sets are differentiated via the text-domain value in the "use" statement: use Log::Report 'my-domain'; There are many things you can configure per (text)domain. This is not only related to translations, but also -for instance- for text formatting configuration. The administration for the configuration is managed in this package. Extends "DESCRIPTION" in Log::Report::Minimal::Domain. METHODSExtends "METHODS" in Log::Report::Minimal::Domain.ConstructorsExtends "Constructors" in Log::Report::Minimal::Domain.
AttributesExtends "Attributes" in Log::Report::Minimal::Domain.
ActionExtends "Action" in Log::Report::Minimal::Domain.
DETAILSConfiguringConfiguration of a domain can happen in many ways: either explicitly or implicitly. The explicit form:package My::Package; use Log::Report 'my-domain'; textdomain 'my-domain', %configuration; textdomain->configure(%configuration); textdomain->configure(\%configuration); textdomain->configure(conf => $filename); The implicit form is (no variables possible, only constants!) package My::Package; use Log::Report 'my-domain', %configuration; use Log::Report 'my-domain', conf => '/filename'; You can only configure your domain in one place in your program. The textdomain setup is then used for all packages in the same domain. This also works for Log::Report::Optional, which is a dressed-down version of Log::Report. configuring your own formatter [0.91] The "PRINTI" is a special constants for configure(formatter), and will use String::Print function "printi()", with the standard tricks. textdomain 'some-domain' formatter => { class => 'String::Print' # default , method => 'sprinti' # default , %options # constructor options for the class ); When you want your own formatter, or configuration of "String::Print", you need to pass a CODE. Be aware that you may loose magic added by Log::Report and other layers, like Log::Report::Template: textdomain 'some-domain' , formatter => \&my_formatter; configuring global values Say, you log for a (Dancer) webserver, where you wish to include the website name in some of the log lines. For this, (ab)use the translation context: ### first enabled translation contexts use Log::Report 'my-domain', context_rules => {}; # or use Log::Report 'my-domain'; textdomain->configure(context_rules => {}); # or textdomain 'my-domain' , content_rules => {}; ### every time you start working for a different virtual host (textdomain 'my-domain')->setContext(host => $host); ### now you can use that in your code package My::Package; use Log::Report 'my-domain'; error __x"in {_context.host} not logged-in {user}", user => $username; SEE ALSOThis module is part of Log-Report distribution version 1.33, built on July 17, 2021. Website: http://perl.overmeer.net/CPAN/LICENSECopyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
Visit the GSP FreeBSD Man Page Interface. |