App::CELL(3pm)

App::CELL3pm

Configuration, error-handling, localization, and logging

Usage

    # imagine you have a script/app called 'foo' . . . 
    use Log::Any::Adapter ( 'File', "/var/tmp/foo.log" );
    use App::CELL qw( $CELL $log $meta $site );
    # load config params and messages from sitedir
    my $status = $CELL->load( sitedir => '/etc/foo' );
    return $status unless $status->ok;
    # set appname to FOO_APPNAME (a config param just loaded from sitedir)
    $CELL->appname( $CELL->FOO_APPNAME || "foo" );
    # write to the log
    $log->notice("Configuration loaded from /etc/foo");
    # get value of site configuration parameter FOO_PARAM
    my $val = $site->FOO_PARAM;
    # get a list of all supported languages
    my @supp_lang = $CELL->supported_languages;
    # determine if a language is supported
    print "sk supported" if $CELL->language_supported('sk');
    # get message object and text in default language
    $status = $CELL->msg('FOO_INFO_MSG');
    my $fmsg = $status->payload if $status->ok;
    my $text = $fmsg->text;
    # get message object and text in default language
    # (message that takes arguments)
    $fmsg = $CELL->msg('BAR_ARGS_MSG', "arg1", "arg2");
    print $fmsg->text, "\n";
    # get text of message in a different language
    my $sk_text = $fmsg->lang('sk')->text;

Version

Version 0.231

Overview

This is the top-level module of App::CELL, the Configuration, Error-handling, Localization, and Logging framework for applications (or scripts) written in Perl.

For details, read the POD in the App::CELL distro. For an introduction, read App::CELL::Guide.

Exports

This module provides the following exports:

$CELL - App::CELL singleton object
$log - App::CELL::Log singleton object
$meta - App::CELL::Config singleton object
$core - App::CELL::Config singleton object
$site - App::CELL::Config singleton object

Methods

appname

If no argument is given, returns the "appname" -- i.e. the name of the application or script that is using App::CELL for its configuration, error handling, etc.

If an argument is given, assumes that it denotes the desired "appname" and sets it. Also initializes the logger.

enviro

Get the "enviro" attribute, i.e. the name of the environment variable containing the sitedir

loaded

Get the current load status, which can be any of the following:
0 nothing loaded yet
'SHARE' sharedir loaded
'BOTH' sharedir _and_ sitedir loaded

sharedir

Get the "sharedir" attribute, i.e. the full path of the site configuration directory (available only after sharedir has been successfully loaded)

sitedir

Get the "sitedir" attribute, i.e. the full path of the site configuration directory (available only after sitedir has been successfully loaded)

supported_languages

Get list of supported languages. Equivalent to:

    $site->CELL_SUPP_LANG || [ 'en ]

language_supported

Determine if a given language is supported.

"load"

Attempt to load messages and configuration parameters from the sharedir and, possibly, the sitedir as well.

Takes: a PARAMHASH that should include at least one of "enviro" or "sitedir" (if both are given, "enviro" takes precedence with "sitedir" as a fallback). The PARAMHASH can also include a "verbose" parameter which, when set to a true value, causes the load routine to log more verbosely.

Returns: an "App::CELL::Status" object, which could be any of the following:
OK success
WARN previous call already succeeded, nothing to do
ERR failure

On success, it also sets the "CELL_META_START_DATETIME" meta parameter.

Status constructors

The following "factory" makes a bunch of status constructor methods (wrappers for App::CELL::Status->new )

status_crit

Constructor for 'CRIT' status objects

status_critical

Constructor for 'CRIT' status objects

status_debug

Constructor for 'DEBUG' status objects

status_emergency

Constructor for 'DEBUG' status objects

status_err

Constructor for 'ERR' status objects

status_error

Constructor for 'ERR' status objects

status_fatal

Constructor for 'FATAL' status objects

status_info

Constructor for 'INFO' status objects

status_inform

Constructor for 'INFORM' status objects

status_not_ok

Constructor for 'NOT_OK' status objects

status_notice

Constructor for 'NOTICE' status objects

status_ok

Constructor for 'OK' status objects

status_trace

Constructor for 'TRACE' status objects

status_warn

Constructor for 'WARN' status objects

status_warning

Constructor for 'WARNING' status objects

msg

Construct a message object (wrapper for App::CELL::Message::new)

Releases

5 releases since Debian 9 (Stretch); the text changed 3 times.

  1. 9
  2. 10
  3. 11
  4. 12–13

From libapp-cell-perl 0.231-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.