The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::CELL - Configuration, Error-handling, Localization, and Logging

VERSION

Version 0.137

SYNOPSIS

    # imagine you have a script/app called 'foo' . . . 

    use Log::Any::Adapter ( 'File', "/var/tmp/foo.log" );
    use App::CELL qw( $CELL $log );

    # load config params and messages from sitedir
    my $status = $CELL->load( appname => 'foo', 
                              sitedir => '/etc/foo' );
    return $status unless $status->ok;

    # write to the log
    $log->notice("Configuration loaded from /etc/foo");

    # get value of config param
    $conf_param = $CELL->config('FOO_CONF_PARAM');

    # get text of message
    print $CELL->msg('FOO_INFO_MSG')->lang('en')->text;

DESCRIPTION

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, see the documentation below and in App::CELL::Guide.

EXPORTS

This module provides the following exports:

$CELL - App::CELL singleton object
$log - App::CELL::Log singleton object

METHODS

appname

Get the appname attribute, i.e. the name of the application or script that is using App::CELL for its configuration, error handling, etc.

enviro

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

loaded

Get the loaded attribute, 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 $supported_languages array ref from App::CELL::Message

load

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

Takes: a PARAMHASH that should include appname and at least one of enviro or sitedir (if both are given, enviro takes precedence with sitedir as a fallback).

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.

set_meta

Set a meta parameter. Wrapper for App::CELL::Config::set_meta. Takes two arguments: string containing name of meta parameter, and value (scalar, arrayref, or hashref) to assign to the parameter. Returns a status object.

meta

Get value of a meta parameter. Wrapper for App::CELL::MetaConfig::get_param. Takes one argument: string containing name of meta parameter. Returns value of meta parameter if the parameter exists, otherwise undef.

config

The config method provides clients access to site configuration parameters. A simple logic is applied: if the parameter is defined in 'site', we're done: that is the value. If the parameter is not defined in 'site', check 'core' and use that value, if available.

If neither 'site' nor 'core' has a definition for the parameter, undef is returned.

LICENSE

App::CELL is Copyright (C) 2014, SUSE LLC

    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 3 of the License, 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, see <http://www.gnu.org/licenses/>.

Author: Nathan Cutler mailto:presnypreklad@gmail.com

    If the above link doesn't work for any reason, the full text of the license
    can also be found in the "LICENSE" file, located in the top-level directory 
    of the App::CELL distro (i.e. in the same directory where this README file 
    is located)