# 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);
See SYNOPSIS in Log::Report::Minimal::Domain
Log::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.
See DESCRIPTION in Log::Report::Minimal::Domain
Configuration 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
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.
The PRINTI
and PRINTP
are special constants for configure(formatter),
and will use String::Print functions printi()
respectively printp()
in their default modus. When you want your own formatter, or configuration
of String::Print
, you need to pass a code reference.
my $sp = String::Print->new ( modifiers => ... , serializers => ... ); textdomain 'some-domain' , formatter => sub { $sp->printi(@_) };