App::CELL(3pm)

πŸ“¦
version 0.231 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’– App::CELL πŸ’–

okay bestie, this is App::CELL β€” a Perl manual page (perldoc calls it App::CELL(3pm), a user-contributed Perl doc, iykyk). it's the whole Configuration, Error-handling, Localization, and Logging situation, all in one module. say it with me: CELL. cute, right? πŸŽ€


✨ VERSION ✨

Version 0.231 β€” that's the one we're on, no cap.


🌈 SYNOPSIS 🌈

ok so picture this: you have a script/app and it's literally called foo...

# 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;

like. look at it. it's serving. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This is the top-level module of App::CELL β€” the Configuration, Error-handling, Localization, and Logging framework for applications (or scripts, we don't discriminate 🫢) written in Perl.

For details, read the POD in the App::CELL distro. For an introduction, read App::CELL::Guide. (yes bestie, go read the guide, it's giving tutorial energy.)


🌸 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

three whole Config singletons, they're a trio, iconic behavior fr fr.


πŸ”₯ METHODS πŸ”₯

appname

If no argument is given, it 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, it assumes that argument denotes the desired "appname" and sets it. It also initializes the logger. two birds, one slay. ✨

enviro

Get the "enviro" attribute β€” i.e. the name of the environment variable containing the sitedir.

loaded

Get the current load status. it can be any of these:

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. heads up: this is available only after sharedir has been successfully loaded. no loading, no peeking πŸ™ˆ

sitedir

Get the "sitedir" attribute β€” i.e. the full path of the site configuration directory. same deal: available only after sitedir has been successfully loaded.

supported_languages

Get the list of supported languages. Equivalent to:

$site->CELL_SUPP_LANG || [ 'en ]

(that's literally what the source says, bestie, brackets and all, I am not touching it πŸ’€)

language_supported

Determine if a given language is supported. that's it. that's the method. 🧚

"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. chatty load, we love her. πŸ—£οΈ

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

bestie real talk: yes, status_emergency says 'DEBUG'. that is what the page says. I am not gaslighting you, I am reporting the lore exactly as written. πŸ’€

msg

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


Copyright (c) 2014-2020, SUSE LLC

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of SUSE LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


and that's the whole page, bestie!! 🫢 this cutie was built against perl v5.34.0 and stamped 2022-07-17 β€” go forth and configure, error-handle, localize, and log. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from