App-CELL
view release on metacpan or search on metacpan
- Guide.pm: mention how to log to STDERR
- t/critic.t: add Perl::Critic-based testing
- README.rst: add info for code maintainer
0.228 2020-02-11 18:06 CET
- README.rst: double up colons before indented passages
- README.rst: mention "Check Manifest" tests explicitly
- travis: try Perl 5.28 in addition to 5.24
0.229 2020-02-12 12:13 CET
- Qualify all calls to CORE::caller()
- t/034-status-dump.t: use Test::Output
0.230 2022-06-28 11:18 CEST
- CONTRIBUTING.rst: add new file
- bootstrap.sh: add new file and update README.rst
0.231 2022-06-28 12:05 CEST
- MANIFEST.SKIP: add bootstrap.sh
- bootstrap.sh: install cpanspec package
lib/App/CELL.pm view on Meta::CPAN
" with arguments " . stringify_args( \%ARGS ),
cell => 1, suppress_caller => 1 );
# we only get past this next call if at least the sharedir loads
# successfully (sitedir is optional)
$status = App::CELL::Load::init( %ARGS );
return $status unless $status->ok;
$log->info( "App::CELL has finished loading messages and site conf params",
cell => 1 ) if $meta->CELL_META_LOAD_VERBOSE;
$log->show_caller( $site->CELL_LOG_SHOW_CALLER );
$log->debug_mode ( $site->CELL_DEBUG_MODE );
$App::CELL::Message::supp_lang = $site->CELL_SUPP_LANG || [ 'en' ];
$App::CELL::Message::def_lang = $site->CELL_DEF_LANG || 'en';
$meta->set( 'CELL_META_START_DATETIME', utc_timestamp() );
$log->info( "**************** App::CELL $VERSION loaded and ready ****************",
cell => 1, suppress_caller => 1 );
return App::CELL::Status->ok;
lib/App/CELL.pm view on Meta::CPAN
if ( @ARGS % 2 ) { # odd number of arguments
$log->warn( "status_$level_lc called with odd number (" .
scalar @ARGS .
") of arguments; discarding the arguments!" );
@ARGS = ();
}
my %ARGS = @ARGS;
return App::CELL::Status->new(
level => $level_uc,
code => $code,
caller => [ CORE::caller() ],
%ARGS,
);
}
}
}
=head3 status_crit
Constructor for 'CRIT' status objects
lib/App/CELL/Config.pm view on Meta::CPAN
ones (meta only). Takes two arguments: parameter name and new value.
Returns a status object.
=cut
sub set {
my ( $self, $param, $value ) = @_;
return App::CELL::Status->not_ok if not blessed $self;
my %ARGS = (
level => 'OK',
caller => [ CORE::caller() ],
);
if ( $self->{'CELL_CONFTYPE'} eq 'meta' ) {
if ( exists $meta->{$param} ) {
%ARGS = (
%ARGS,
code => 'CELL_OVERWRITE_META_PARAM',
args => [ $param, ( defined( $value ) ? $value : 'undef' ) ],
);
#$log->debug( "Overwriting \$meta->$param with ->$value<-", cell => 1 );
} else {
lib/App/CELL/Guide.pm view on Meta::CPAN
code => 'CODE1',
args => [ 'foo', 'bar' ],
);
It is also possible to report the caller's filename and line number:
# relative to my caller
App::CELL::Status->new( level => 'ERR',
code => 'CODE1',
args => [ 'foo', 'bar' ],
caller => [ CORE::caller() ],
);
It is also possible to pass a message object in lieu of C<code> and
C<msg_args> (this could be useful if we already have an appropriate message
on hand):
# with pre-existing message object
App::CELL::Status->new( level => 'ERR',
msg_obj => $my_msg;
);
lib/App/CELL/Load.pm view on Meta::CPAN
sub _report_load_status {
my ( $dir_path, $dir_desc, $what, $status ) = @_;
my $return_status = App::CELL::Status->ok;
my $quantitems = ${ $status->payload }{quantitems} || 0;
my $quantfiles = ${ $status->payload }{quantfiles} || 0;
if ( $quantitems == 0 ) {
$return_status = App::CELL::Status->new(
level => 'WARN',
code => 'CELL_DIR_WALKED_NOTHING_FOUND',
args => [ $what, $dir_desc, $dir_path, $quantfiles ],
caller => [ CORE::caller() ],
cell => 1,
);
}
# trigger a log message: note that we can't use an OK status here
# because log messages for those are suppressed
App::CELL::Status->new (
level => 'INFO',
code => 'CELL_DIR_WALKED_ITEMS_LOADED',
args => [ $quantitems, $what, $quantfiles, $dir_desc, $dir_path ],
caller => [ CORE::caller() ],
cell => 1,
) if ( $dir_desc eq 'sitedir' ) or ( $dir_desc eq 'sharedir' and $meta->CELL_META_LOAD_VERBOSE );
return $return_status;
}
=head2 message_files
Loads message files from the given directory. Takes: full path to
configuration directory. Returns: result hash containing 'quantfiles'
(total number of files processed) and 'count' (total number of
lib/App/CELL/Message.pm view on Meta::CPAN
my ( $class, %ARGS ) = @_;
my $stringified_args = stringify_args( \%ARGS );
my $my_caller;
my $msgobj = {};
#$log->debug( "Entering Message->new called from " . (caller)[1] . " line " . (caller)[2]);
if ( $ARGS{called_from_status} ) {
$my_caller = $ARGS{caller};
} else {
$my_caller = [ CORE::caller() ];
}
if ( not exists( $ARGS{'code'} ) ) {
return App::CELL::Status->new( level => 'ERR',
code => 'CELL_MESSAGE_NO_CODE',
caller => $my_caller,
);
}
if ( not $ARGS{'code'} ) {
return App::CELL::Status->new( level => 'ERR',
lib/App/CELL/Status.pm view on Meta::CPAN
my %ARGS = @ARGS;
my $self;
# default to ERR level
unless ( defined $ARGS{level} and grep { $ARGS{level} eq $_ } $log->permitted_levels ) {
$ARGS{level} = 'ERR';
}
# if caller array not given, create it
if ( not $ARGS{caller} ) {
$ARGS{caller} = [ CORE::caller() ];
}
$ARGS{args} = [] if not defined( $ARGS{args} );
$ARGS{called_from_status} = 1;
if ( $ARGS{code} ) {
# App::CELL::Message->new returns a status object
my $status = $class->SUPER::new( %ARGS );
if ( $status->ok ) {
my $parent = $status->payload;
lib/App/CELL/Status.pm view on Meta::CPAN
my $ARGS = {};
if ( blessed $self )
{ # instance method
return 1 if ( $self->level eq 'OK' );
return 0;
}
$ARGS->{level} = 'OK';
$ARGS->{payload} = $payload if $payload;
$ARGS->{caller} = [ CORE::caller() ];
return bless $ARGS, __PACKAGE__;
}
=head2 not_ok
Similar method to 'ok', except it handles 'NOT_OK' status.
When called as an instance method, returns a true value if the status level
is anything other than 'OK'. Otherwise false.
lib/App/CELL/Status.pm view on Meta::CPAN
my ( $self, $payload ) = @_;
my $ARGS = {};
if ( blessed $self )
{ # instance method
return 1 if $self->{level} ne 'OK';
return 0;
}
$ARGS->{level} = 'NOT_OK';
$ARGS->{payload} = $payload if $payload;
$ARGS->{caller} = [ CORE::caller() ];
return bless $ARGS, __PACKAGE__;
}
=head2 level
Accessor method, returns level of status object in ALL-CAPS. All status
objects must have a level attribute.
=cut
( run in 1.078 second using v1.01-cache-2.11-cpan-b61123c0432 )