view release on metacpan or search on metacpan
t/data/Dictionary/en/backup.dict
t/data/Dictionary/en/dtest.dict
t/data/Emailer/email.tt
t/data/Emailer/email_wrap.tt
t/data/Emailer/html_body.tt
t/data/Emailer/html_footer.tt
t/data/Emailer/html_header.tt
t/data/Emailer/registry.yml
t/data/Emailer/test-mission.doc
t/data/Log-disabling.yml
t/data/Log-log4perl.conf
t/data/Registry-advanced.yml
t/data/Registry-dyn.yml
t/data/Registry-test-no-act-realm.yml
t/data/Registry-test.yml
t/data/test_project/org.yml
t/data/test_project/test.yml
t/data/test_project/USER.yml
t/DB.t
t/Dictionary-default.t
t/Dictionary-dies.t
bin/activator.pl view on Meta::CPAN
=head1 SYNOPSIS
activator.pl [OPTIONS] ACTION project-name
Actions
sync : sync user codebase to target install base
Options:
--restart : (re)start the webserver after performing <ACTION>
--log_level : One of TRACE, DEBUG, INFO, WARN, ERROR, FATAL (see L<Activator::Log>)
--sync_dir : ignore sync_dir setting from configuration, use this.
Todo:
--activator_codebase=<path> : use alternate Activator codebase (for Activator development)
See L<Activator::Tutorial> for a description of how to configure an Activator project.
=cut
# $config, $args, $project, $action and the current apache pid are globally interesting
bin/activator.pl view on Meta::CPAN
try eval {
# Act::Config requires that project be set via an option or be the
# last arg, hence the flag after undef below
$config = Activator::Config->get_config( \@ARGV, undef, 1 );
};
if ( catch my $e ) {
die( "Error while processing command line options: $e" );
}
my $log_level = $config->{log_level} || 'WARN';
if ( $config->{v} || $config->{verbose} ) {
Activator::Log->level( 'INFO' );
}
$action = $ARGV[-2];
$project = $ARGV[-1];
if ( $action eq 'sync' ) {
&sync( $project );
}
bin/activator.pl view on Meta::CPAN
# these commands need to run to create the target installation
my @cmds = (
# blow away the target dir
"rm -rf $config->{sync_target}",
"mkdir -p $config->{sync_target}",
"mkdir -p $config->{sync_run_dir}",
"mkdir -p $config->{sync_lock_dir}",
"mkdir -p $config->{sync_conf_dir}",
"mkdir -p $config->{sync_log_dir}",
"mkdir -p $perl5lib",
"mkdir -p $document_root",
"mkdir -p $server_root/logs",
# all your perl lib are belong to PERL5LIB
"rsync -a $rsync_flags $project_codebase/lib/* $perl5lib",
# symlink template files so we don't have to restart server
# not that this symlinks INTO document root
"ln -sf $project_codebase/root $document_root",
# symlink apache modules
"ln -sf /usr/lib/httpd/modules $server_root",
# symlink apache log files
"ln -sf $server_root/logs $config->{sync_log_dir}/httpd",
);
if ( $config->{activator_codebase} ) {
push @cmds,
"rsync -a $rsync_flags ".$config->{activator_codebase}."/lib/* $perl5lib";
}
if ( $config->{sync_data_dirs} ) {
bin/activator.pl view on Meta::CPAN
WARN( "Couldn't process Template file '$config_file'");
next;
}
# $fq_dest_file = "$config->{sync_conf_dir}/$out";
my $tt = Template->new( { DEBUG => 1,
ABSOLUTE => 1,
OUTPUT_PATH => $config->{sync_conf_dir},
}
);
DEBUG( qq(tt processing: $fq_source_file, $config, $out ));
$tt->process( $fq_source_file, $config, $out ) || Activator::Log->logdie( $tt->error()."\n");
}
# just copy the file
else {
my $rsync_flags = ( $config->{debug} ? '-v' : '' );
$rsync_flags .= ' --cvs-exclude';
my $cmd = "rsync -a $rsync_flags $fq_source_file $fq_dest_file";
die "$cmd failed" unless !system( $cmd );
}
}
&restart();
}
sub restart {
my $httpd_conf = $config->{apache2}->{ServerRoot} . '/conf/httpd.conf';
if ( !-f $httpd_conf ) {
Activator::Log->logdie( "apache config not found: '$httpd_conf'");
}
my $httpd_pid = $config->{apache2}->{PidFile};
my $cmd;
if ( $httpd_pid && $httpd_pid =~ /^\d+$/ ) {
INFO("killing pid '$httpd_pid' from pid file");
system( "kill $httpd_pid");
} else {
bin/activator.pl view on Meta::CPAN
$fq =~ m|share/apache2/(.+)\.tt$|;
my $out = $1;
return unless $out;
DEBUG( qq( processing $file into ).$config->{apache2}->{ServerRoot}.'/'.$out );
my $tt = Template->new( { DEBUG => 1,
ABSOLUTE => 1,
OUTPUT_PATH => $config->{apache2}->{ServerRoot},
}
);
$tt->process( $fq, $config, $out ) || Activator::Log->logdie( $tt->error()."\n");
# TODO: use some smart hueristics to properly chmod that which
# should be executable
#
#if( $out =~ m@/s?bin/|/init.d/@ ) {
# chmod 0755, $config->{apache2}->{ServerRoot}.'/'.$out
#}
}
# copy the default project config for a catalyst app to the correct
lib/Activator.pm view on Meta::CPAN
=item *
Role-based project configuration supporting development, QA, and production needs
=item *
A globally accessible variable registry for all components within a project including the Catalyst web app, crons and daemons
=item *
Key/Value dictionary lookups provide context sensitive messages to users and/or logs
=item *
Template based email using a role-based delivery mechanism
=item *
Role based logging utilizing Log4Perl
=item *
Global database access definitions allowing generic abstraction of database queries (supports intentionally avoiding an ORM)
=item *
Role and configuration file aware command line options processing
=back
lib/Activator/DB.pm view on Meta::CPAN
# _get_cur_conn
#
# return the internal connection hash for the current connection alias
sub _get_cur_conn {
my ( $self ) = @_;
if ( exists( $self->{connections}->{ $self->{cur_alias} } ) ) {
my $conn = $self->{connections}->{ $self->{cur_alias} };
# # set the log level to this connection
# LEVEL( $conn->{config}->{debug}
# ? $Log::Log4perl::$self->_debug
# : $Log::Log4perl::WARN );
return $conn;
}
Activator::Exception::DB->throw('alias', 'invalid', $self->{cur_alias} )
}
# explode args for a db query sub
sub _explode {
lib/Activator/DB.pm view on Meta::CPAN
return $res;
}
return $sth;
}
################################################################################
# getrow subs
#
# Note that we jump through some hoops ( return array of everything )
# to consolidate these 3 functions, and still log from the appropriate
# function.
#
sub getrow {
my ($self, $sql, $bind, $args, @ret) = &_fetch( 'getrow', @_);
return @ret;
}
sub getrow_arrayref {
my ($self, $sql, $bind, $args, $ret) = &_fetch( 'getrow_arrayref', @_);
return $ret;
lib/Activator/DB.pm view on Meta::CPAN
=item *
Only tested with MySql and PostgreSQL
=back
=head1 CONFIGURATION
This module uses L<Activator::Registry> to automatically choose default
databases, and L<Activator::Log> to log warnings and errors.
=head2 Registry Setup (from Activator::Registry)
This module expects an environment variable ACT_REG_YAML_FILE to be
set. If you are utilizing this module from apache, this directive must
be in your httpd configuration:
SetEnv ACT_REG_YAML_FILE '/path/to/config.yml'
If you are using this module from a script, you need to insure that
lib/Activator/DB.pm view on Meta::CPAN
BEGIN{
$ENV{ACT_REG_YAML_FILE} ||= '/path/to/config.yml'
}
=head2 Registry Configuration
Add an C<Activator::DB> section to your project YAML configuration file:
'Activator::Registry':
log4perl<.conf>: # Log4perl config file or definition
# See Logging Configuration below
'Activator::DB':
default: # default configuration for all connections
connection: <conn_alias>
## Optional default attributes and config for all connections
config:
debug: 0/1 # default: 0, affects all queries, all aliases
reconn_att: <int> # attempt reconnects this many times. default: 3
reconn_sleep: <int> # initial sleep seconds between reconnect attempts.
lib/Activator/Dictionary.pm view on Meta::CPAN
large numbers of program instances. That being said, it can be
relatively memory efficient when used for a single language deployment
in an application that provides multiple language support.
An C<Activator::Dictionary> object can have multiple realms: that is, you
could have a 'web' dictionary for the website text, an 'error'
dictionary for backend job messages, and any number of other realms
needed for your application. This allows you to separate the
translatable texts from each other so that, for example, the web
frontend of your application could give a user friendly message using
the 'web' realm, and the backend could use the 'error' realm to log
something much more useful to a technician.
Note that there can be great amounts of complexity localizing language
within an application. This module is for the simple cases, where you
just have key/value lookups. If you need complex conjugations, object
sensitive pluralization, you should look into the existing
L<Locale::Maketext>, or the upcoming L<Activator::Lexicon> module. It
is highly recommended that you read
L<http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod>
before making a decision as to which localization method your
lib/Activator/Dictionary.pm view on Meta::CPAN
return empty string
=head1 DISABLING LOAD WARNING
When loading dictionary files, you may sometimes see:
[WARN] Couldn't load dictionary from file for <lang>
If you are using files for one language, and the DB for another, this
could get really annoying since you KNOW THIS TO BE TRUE. The
workaround is to set the log level for this message an alternate level
of FATAL, ERROR, WARN, INFO, DEBUG, or TRACE. For example:
$dict->{LOG_LEVEL_FOR_FILE_LOAD} = 'INFO';
=head1 METHODS
=head2 lookup($key, $realm)
OO Usage:
lib/Activator/Dictionary.pm view on Meta::CPAN
if ( defined( $self->{config}->{dict_files} ) ) {
my $dir_loc = $self->{config}->{dict_files};
$dir_loc =~ s|/$||;
$dir_loc .= "/$lang";
if (!opendir( DIR, $dir_loc ) ) {
local $Log::Log4perl::caller_depth;
$Log::Log4perl::caller_depth += 3;
# This message could be annoying in some situations, so
# allow changing the log level for just this one.
my $msg = "Couldn't load dictionary from file for $lang from $dir_loc";
my $level = $self->{LOG_LEVEL_FOR_FILE_LOAD};
if ( $level =~ /FATAL|ERROR|WARN|INFO|DEBUG|TRACE/ ) {
no strict 'refs';
&$level( $msg );
}
else {
WARN( $msg );
}
}
lib/Activator/Log.pm view on Meta::CPAN
use base 'Class::StrongSingleton';
=head1 NAME
Activator::Log - provide a simple wrapper for L<Log::Log4perl> for use
within an Activator project.
=head1 SYNOPSIS
use Activator::Log;
Activator::Log::WARN( $msg ); # logs to default logger
Activator::Log->WARN( $msg, $other_logger ); # logs to other logger, don't change default
# NOTE: you MUST use arrow notation!
use Activator::Log qw( :levels );
WARN( $msg );
#### Use alternate default log levels
Activator::Log->default_level( $level );
#### Use alternate default loggers
Activator::Log->default_logger( $logger_name );
=head1 DESCRIPTION
This module provides a simple wrapper for L<Log::Log4perl> that allows
you to have a project level configuration for Log4perl, and have any
class or script in your project be configured and output log messages
in a consistent centralized way.
Additionally, C<TRACE> and C<DEBUG> functions have the extra
capabilities to turn logging on and off on a per-module basis. See the
section L<DISABLING DEBUG OR TRACE BY MODULE> for more information.
=head2 Centralized Configuration
Your project C<log4perl.conf> gets loaded based on your
L<Activator::Registry> configuration. If you do not have a Log4perl
config available, the log level is set to WARN and all output goes to
STDERR.
See the section L<CONFIGURATION> for more details.
=head2 Exporting Level Functions
Log::Log4perl logging functions are exported into the global
namespace if you use the C<:levels> tag
use Activator::Log qw( :levels );
&FATAL( $msg );
&ERROR( $msg );
&WARN( $msg );
&INFO( $msg );
&DEBUG( $msg );
&TRACE( $msg );
lib/Activator/Log.pm view on Meta::CPAN
Activator::Log->FATAL( $msg );
Activator::Log->ERROR( $msg );
Activator::Log->WARN( $msg );
Activator::Log->INFO( $msg );
Activator::Log->DEBUG( $msg );
Activator::Log->TRACE( $msg );
=head2 Using Alternate Loggers
You can set the default logger dynamically:
Activator::Log->default_logger( 'My.Default.Logger' );
Note that since C<Activator::Log> is a singleton, this sub will set
the level for the entire process. This is probably fine for cron jobs,
not so good for web processes.
You can avoid trouble by logging to an alternate Log4perl logger
without changing the default logger:
Activator::Log->DEBUG( $msg, 'My.Configured.Debug.Logger' );
=head2 Setting Log Level Dynamically
You can set the minimum level with the C<default_level> sub:
# only show only levels WARN, ERROR and FATAL
Activator::Log->default_level( 'WARN' );
# only show only levels ERROR and FATAL
Activator::Log->default_level( 'ERROR' );
Note that since C<Activator::Log> is a singleton, this sub will set
the level for the entire process. This is probably fine for cron jobs,
not so good for web processes.
=head2 Additional Functionality provided
The following Log::Log4perl subs you would normally call with
$logger->SUB are supported through a static call:
Activator::Log->logwarn( $msg );
Activator::Log->logdie( $msg );
Activator::Log->error_warn( $msg );
Activator::Log->error_die( $msg );
Activator::Log->logcarp( $msg );
Activator::Log->logcluck( $msg );
Activator::Log->logcroak( $msg );
Activator::Log->logconfess( $msg );
Activator::Log->is_trace()
Activator::Log->is_debug()
Activator::Log->is_info()
Activator::Log->is_warn()
Activator::Log->is_error()
Activator::Log->is_fatal()
See the L<Log::Log4perl> documentation for more details.
=head1 CONFIGURATION
=head2 Log::Log4perl
Activator::Log looks in your Registry for a L<Log::Log4perl>
configuration in this heirarchy:
1) A 'log4perl.conf' file in the registry:
Activator:
Log:
log4perl.conf: <file>
2) A 'log4perl' config in the registry:
Activator:
Log:
log4perl:
'log4perl.key1': 'value1'
'log4perl.key2': 'value2'
... etc.
3) If none of the above are set, C<Activator::Log> defaults to showing WARN level to
C<STDERR> as shown in this log4perl configuration:
log4perl.logger.Activator.Log = WARN, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %d{yyyy-mm-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n
NOTE: If C<log4perl.conf> or C<log4perl> is set, it is possible you
will see no logging since L<Log::Log4perl> by default doesn't log
anything. That is, you could have configured this module properly, but
still see no logging.
NOTE 2: You must properly configure L<Log::Log4perl> for this module!
NOTE TO SELF: create a test sub to make life easier
=head2 Setting the Default Logger
Log4Perl can have multiple definitions for loggers. If your script or
program has a preferred logger, set the Registry key c<default_logger>:
Activator:
Log:
default_logger: <logger name IN log4perl.conf>
=head2 Setting the Default Log Level
Set up your registry as such:
Activator:
Log:
default_level: LEVEL
Note that you can also initialize an instance of this module with the
same affect:
Activator::Log->new( $level );
=head1 DISABLING DEBUG OR TRACE BY MODULE
By default, this module will print all C<DEBUG> and C<TRACE> log messages
provided that the current log level is high enough. However, when
developing it is convenient to be able to turn debugging/tracing on
and off on a per-module basis. The following examples show how to do
this.
=head2 Turn debugging OFF on a per-module basis
Activator:
Log:
DEBUG:
'My::Module': 0 # My::Module will now prove "silence is bliss"
lib/Activator/Log.pm view on Meta::CPAN
DEBUG:
FORCE_EXPLICIT: 1
'My::Module': 1 # only My::Module messages will be debugged
TRACE:
FORCE_EXPLICIT: 1
'Other::Module': 1 # only Other::Module messages will be traced
=head2 Disabling Caveats
Note that the entire Activator framework uses this module, so use
FORCE_EXPLICIT with caution, as you may inadvertantly disable logging
from a package you DO want to hear from.
=head1 USING THIS MODULE IN WRAPPERS
This module respects C<$Log::Log4perl::caller_depth>. When using this
module from a wrapper, you can insure that the message appears to come
from your module as such:
{
local $Log::Log4perl::caller_depth;
$Log::Log4perl::caller_depth += $depth;
Debug( 'some message' );
}
You'll likely want to do this in a sub routine if you do a lot of logging.
See also the full description of this technique in "Using
Log::Log4perl from wrapper classes" in the Log4perl FAQ.
=cut
# constructor: implements singleton
sub new {
my ( $pkg, $level ) = @_;
my $self = bless( { }, $pkg);
$self->_init_StrongSingleton();
if ( Log::Log4perl->initialized() ) {
# do nothing, logger already set
}
else {
# old config format
my $config =
Activator::Registry->get('Activator::Log') ||
Activator::Registry->get('Activator->Log');
$self->{DEFAULT_LEVEL} =
$level ||
$config->{default_level} ||
'WARN';
$l4p_config = $ENV{ACT_LOG_log4perl} ||
Activator::Registry->get('log4perl.conf') ||
Activator::Registry->get('log4perl') ||
$config->{'log4perl.conf'} ||
$config->{'log4perl'} ||
{ 'log4perl.logger.Activator.Log' => 'ALL, DEFAULT',
'log4perl.appender.DEFAULT' => 'Log::Log4perl::Appender::Screen',
'log4perl.appender.DEFAULT.layout' => 'Log::Log4perl::Layout::PatternLayout',
'log4perl.appender.DEFAULT.layout.ConversionPattern' => '%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n',
};
Log::Log4perl->init_once( $l4p_config );
if ( !Log::Log4perl->initialized() ) {
warn( "ERROR: Activator::Log couldn't initialize logger with config $l4p_config");
}
$Log::Log4perl::caller_depth++;
# look for a specific logger to use
if ( exists $config->{default_logger} ) {
# TODO: detect invalid logger config
$self->{DEFAULT_LOGGER} = Log::Log4perl->get_logger( $config->{default_logger} );
}
else {
if ( ! ( $self->{DEFAULT_LOGGER} = Log::Log4perl->get_logger( 'Activator.Log' ) ) ) {
# they defined a Log4perl config, but no default_logger.
die q(ERROR: Activator::Log: If you define 'log4perl' in your registry, you must define 'default_logger' too.);
}
}
}
return $self;
}
# backwards compatibility to <1.0
sub level {
&default_level( @_ );
}
sub default_level {
my ( $pkg, $level ) = @_;
my $self = &new( 'Activator::Log' );
$level = &_get_static_arg( $pkg, $level );
$self->{DEFAULT_LOGGER}->level( $level );
}
sub default_logger {
my ( $pkg, $logger ) = @_;
my $self = &new( 'Activator::Log' );
$logger = &_get_static_arg( $pkg, $logger );
$self->{DEFAULT_LOGGER} = Log::Log4perl->get_logger( $logger )
}
sub FATAL {
my ( $pkg, $msg, $logger_label ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->fatal( $msg );
}
sub ERROR {
my ( $pkg, $msg, $logger_label ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->error( $msg );
}
sub WARN {
my ( $pkg, $msg, $logger_label ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->warn( $msg );
}
sub INFO {
my ( $pkg, $msg, $logger_label ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->info( $msg );
}
sub DEBUG {
my ( $pkg, $msg, $logger_label ) = @_;
my $caller = caller;
my $self = &new( 'Activator::Log' );
my $debug = &_enabled( 'DEBUG', $caller );
if ( $debug ) {
$msg = _get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->debug( $msg );
}
}
sub TRACE {
my ( $pkg, $msg, $logger_label ) = @_;
my $caller = caller;
my $self = &new( 'Activator::Log' );
my $trace = &_enabled( 'TRACE', $caller );
if ( $trace ) {
$msg = _get_static_arg( $pkg, $msg );
my $logger = $self->{DEFAULT_LOGGER};
if ( $logger_label ) {
$logger = Log::Log4perl->get_logger( $logger_label );
}
$logger->trace( $msg );
}
}
sub is_fatal {
my $self = &new( 'Activator::Log' );
return $self->{DEFAULT_LOGGER}->is_fatal();
}
sub is_error {
lib/Activator/Log.pm view on Meta::CPAN
sub is_debug {
my $self = &new( 'Activator::Log' );
return $self->{DEFAULT_LOGGER}->is_debug();
}
sub is_trace {
my $self = &new( 'Activator::Log' );
return $self->{DEFAULT_LOGGER}->is_trace();
}
sub logwarn {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->logwarn( $msg );
}
sub logdie {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->logdie( $msg );
}
sub error_warn {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->error_warn( $msg );
}
sub error_die {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->error_die( $msg );
}
sub logcarp {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );B
$self->{DEFAULT_LOGGER}->logcarp( $msg );
}
sub logcluck {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->logcluck( $msg );
}
sub logcroak {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->logcroak( $msg );
}
sub logconfess {
my ( $pkg, $msg ) = @_;
my $self = &new( 'Activator::Log' );
$msg = &_get_static_arg( $pkg, $msg );
$self->{DEFAULT_LOGGER}->logconfess( $msg );
}
sub _enabled {
my ( $level, $pkg ) = @_;
return 1 if !$pkg;
my $log_config =
Activator::Registry->get('Activator::Log') ||
Activator::Registry->get('Activator->Log');
my $config = $log_config->{$level};
my $pkg_setting = -1;
if (exists( $config->{$pkg} ) &&
defined( $config->{$pkg} ) ) {
$pkg_setting = $config->{$pkg};
}
my $force_explicit = -1;
if (exists( $config->{FORCE_EXPLICIT} ) &&
defined( $config->{FORCE_EXPLICIT} ) ) {
$force_explicit = $config->{FORCE_EXPLICIT};
lib/Activator/Registry.pm view on Meta::CPAN
}
if ( $ENV{ACT_REG_YAML_FILE} || $yaml_file ) {
my $msg = "Registry $action failed." .
'Neither $ENV{ACT_REG_YAML_FILE} ('. ( $ENV{ACT_REG_YAML_FILE} || 'undef' ) .
') nor $yaml_file ('. ( $yaml_file || 'undef' ) .
') are a valid configuration file';
# TODO: figure out how to solve the cyclic dependancy problem.
# That is, Log depends on this file to find it's config, so
# when calling new, we can't be guranteed that log is loaded.
# We need to figure out if Log is loaded, then we can just
# warn for the outlier case where Log is configured to a bad
# filename.
warn( "[WARN] $msg" );
}
$registered_something = 0;
}
else {
$registered_something = 1;
}
lib/Catalyst/Plugin/Activator/Config.pm view on Meta::CPAN
=cut
sub load_config {
my $c = shift;
my $ref = shift;
my ( $file, $config ) = %$ref;
$c->config( $config );
$c->log->debug( qq(Loaded Config "$file") )
if $c->debug;
return;
}
=head2 find_files
This method determines the potential file paths to be used for config loading.
It returns an array of paths (up to the filename less the extension) to pass to
L<Config::Any|Config::Any> for loading.
lib/Catalyst/Plugin/Activator/Exception.pm view on Meta::CPAN
else {
push @{ $c->stash->{e} }, Activator::Exception->new( $e );
}
return;
}
sub finalize {
my ($c) = @_;
if ( $c->stash->{e} ) {
## TODO: figure out how to make this work. no level 1-8 makes
## sense from the perspective of the log or the request
#local $Log::Log4perl::caller_depth;
#$Log::Log4perl::caller_depth += 8;
WARN("Execution had error(s)");
foreach my $e ( @{ $c->stash->{e} } ) {
WARN($e);
}
}
delete $c->stash->{e};
return $c->NEXT::finalize(@_);
}
lib/Catalyst/Plugin/SecureCookies.pm view on Meta::CPAN
return $string;
}
=back
=head1 SEE ALSO
L<Catalyst>, L<Digest::SHA1>, L<Crypt::CBC>, L<MIME::Base64>
L<http://www.schneier.com/blog/archives/2005/08/new_cryptanalyt.html>
=head1 AUTHOR
Rob Johnson L<rob@giant-rock.com>
=head1 ACKNOWLEDGEMENTS
* Karim A. Nassar for converting this into a self-contained Catalyst Plugin.
* All the helpful people in #catalyst.
share/apache2/conf/httpd.conf.tt view on Meta::CPAN
# 1. Directives that control the operation of the Apache server process as a
# whole (the 'global environment').
# 2. Directives that define the parameters of the 'main' or 'default' server,
# which responds to requests that aren't handled by a virtual host.
# These directives also provide default values for the settings
# of all virtual hosts.
# 3. Settings for virtual hosts, which allow Web requests to be sent to
# different IP addresses or hostnames and have them handled by the
# same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log".
#
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#
#
# Don't give away too much information about all the subcomponents
# we are running. Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "[% apache2.ServerRoot %]"
share/apache2/conf/httpd.conf.tt view on Meta::CPAN
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
share/apache2/conf/httpd.conf.tt view on Meta::CPAN
#
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
#
#EnableSendfile off
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog logs/error_log
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this
# requires the mod_logio module to be loaded.
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
#CustomLog logs/access_log common
#
# If you would like to have separate agent and referer logfiles, uncomment
# the following directives.
#
#CustomLog logs/referer_log referer
#CustomLog logs/agent_log agent
#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access_log combined
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature On
share/apache2/conf/httpd.conf.tt view on Meta::CPAN
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
share/conf/default-project.yml view on Meta::CPAN
# this is the default realm, and by default we don't define realms in this file
#
act_config_no_realms: 1
#
# default to the production realm
#
realm: production
#
# global debug flag: see perldoc Activator::Log for more specifics on debug logging.
#
debug: 1
#
# This is the name of the project, most likely the top of your perl
# namespace for a catalyst app, i.e.: MyApp
#
project_name:
#
share/conf/default-project.yml view on Meta::CPAN
# where lock files should be placed
#
sync_lock_dir : ${sync_target}/var/lock
#
# where project/application configuration files should be placed
#
sync_conf_dir : ${sync_target}/etc/${project_alias}.d
#
# where project/application log files will be placed
#
sync_log_dir : ${sync_target}/var/log
#
# if your application needs extra directories created for its
# functionality, list them here.
sync_data_dirs :
- ${sync_target}/var/lib/${project_alias}
- ${sync_target}/var/tmp/${project_alias}
#
# Files listed here will be copied from ${conf_dir} to ${sync_conf_dir}. Additionally:
share/conf/default-project.yml view on Meta::CPAN
# - If the file looks like a Template Toolkit file (ends in .tt), it
# is processed with your project config and written with .tt stripped off.
#
# It is OK to have deep dir paths relative to ${conf_dir}. They will be preserved.
#
# Note that most projects need at least these two files listed here:
# one to configure every catalyst thing that is not Activator aware
# (usually ${project_alias}-catalyst.yml), and one to have the multi-
# functional project registry (usually ${project_alias}-registry.yml).
#
# Note also that this is a great place for a log4perl.conf and your
# Activator::Dictionary files (but don't list dictionary files here,
# list them in the Activator: Dictionary: section below)
#
sync_config_files:
- ${project_alias}-registry.yml
- ${project_alias}-catalyst.yml
################################################################################
#
# Default Activator Module Settings
#
Activator:
# Log:
# log4perl : ${sync_conf_dir}/log4perl.conf
# DB:
# db_connection : ${project_alias}
# Dictionary:
# dict_files: ${sync_conf_dir}/dict
################################################################################
#
# Production apache settings. These settings should be suitable for
# generating a production httpd.conf file, and the
# conf.d/<catalyst>.conf file. Override these values in <user>.yml or
t/Log-config-file.t view on Meta::CPAN
#!perl
use warnings;
use strict;
use Activator::Log;
use Activator::Registry;
use Test::More tests => 9;
my $logfile = "/tmp/activator-log-test.log";
my $config = "$ENV{PWD}/t/data/Log-log4perl.conf";
Activator::Registry->register('log4perl.conf', $config );
# tests for all functions
Activator::Log::level( 'TRACE' );
Activator::Log::TRACE('TRACE');
Activator::Log::DEBUG('DEBUG');
Activator::Log::INFO('INFO');
Activator::Log::WARN('WARN');
Activator::Log::ERROR('ERROR');
Activator::Log::FATAL('FATAL');
# test log levels
Activator::Log::level( 'FATAL' );
Activator::Log::TRACE('TRACE');
Activator::Log::DEBUG('DEBUG');
Activator::Log::INFO('INFO');
Activator::Log::WARN('WARN');
Activator::Log::ERROR('ERROR');
Activator::Log::FATAL('FATAL');
my $line;
my $cmd_failed = !open LOG, "<$logfile";
ok( !$cmd_failed, "can open log file" );
foreach my $msg ( qw/ TRACE DEBUG INFO WARN ERROR FATAL / ) {
$line = <LOG>;
ok ( $line =~ /\[$msg\] $msg \(main::/, "$msg logged" );
}
$line = <LOG>;
ok( $line =~ /\[FATAL\] FATAL \(main::/, "Changing log level works" );
$cmd_failed = system ( "rm -f $logfile" );
ok( !$cmd_failed, "rm logfile $logfile" );
t/Log-default.t view on Meta::CPAN
Activator::Log::FATAL('FATAL');
# tests for all functions -> calls
Activator::Log->TRACE('TRACE');
Activator::Log->DEBUG('DEBUG');
Activator::Log->INFO('INFO');
Activator::Log->WARN('WARN');
Activator::Log->ERROR('ERROR');
Activator::Log->FATAL('FATAL');
# test that changing log level does the right thing
Activator::Log::level( 'FATAL' );
Activator::Log->TRACE('TRACE');
Activator::Log->DEBUG('DEBUG');
Activator::Log->INFO('INFO');
Activator::Log->WARN('WARN');
Activator::Log->ERROR('ERROR');
Activator::Log->FATAL('FATAL');
$capture->stop();
t/Log-registry-config.t view on Meta::CPAN
#!perl
use warnings;
use strict;
use Activator::Log;
use Activator::Registry;
use IO::Capture::Stderr;
use Test::More tests => 14;
my $logfile = "/tmp/activator-log-test.log";
my $logfile2 = "/tmp/activator-log-test2.log";
my $config = {
'log4perl.logger.Activator.Log' => 'WARN, LOGFILE',
'log4perl.logger.Activator.Log2' => 'DEBUG, LOGFILE2',
'log4perl.appender.LOGFILE' => 'Log::Log4perl::Appender::File',
'log4perl.appender.LOGFILE.filename' => $logfile,
'log4perl.appender.LOGFILE.mode' => 'append',
'log4perl.appender.LOGFILE.layout' => 'PatternLayout',
'log4perl.appender.LOGFILE.layout.ConversionPattern' => '%d{yyyy-mm-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n,',
'log4perl.appender.LOGFILE2' => 'Log::Log4perl::Appender::File',
'log4perl.appender.LOGFILE2.filename' => $logfile2,
'log4perl.appender.LOGFILE2.mode' => 'append',
'log4perl.appender.LOGFILE2.layout' => 'PatternLayout',
'log4perl.appender.LOGFILE2.layout.ConversionPattern' => '%d{yyyy-mm-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n,',
};
Activator::Registry->register('log4perl', $config );
# tests for all functions
Activator::Log::level( 'TRACE' );
Activator::Log::TRACE('TRACE');
Activator::Log::DEBUG('DEBUG');
Activator::Log::INFO('INFO');
Activator::Log::WARN('WARN');
Activator::Log::ERROR('ERROR');
Activator::Log::FATAL('FATAL');
# change level to FATAL, then only the last line in this block should log
Activator::Log::level( 'FATAL' );
Activator::Log::TRACE('TRACE');
Activator::Log::DEBUG('DEBUG');
Activator::Log::INFO('INFO');
Activator::Log::WARN('WARN');
Activator::Log::ERROR('ERROR');
Activator::Log::FATAL('FATAL');
# log to alternate logger, then orig
Activator::Log::level( 'DEBUG' );
Activator::Log->DEBUG('DEBUG2', 'Activator.Log2');
Activator::Log::DEBUG('DEBUG');
# change default logger, log to it
Activator::Log->default_logger('Activator.Log2');
Activator::Log->DEBUG('DEBUG2');
my $line;
my $cmd_failed = !open LOG, "<$logfile";
ok( !$cmd_failed, "can open log file" );
$cmd_failed = !open LOG2, "<$logfile2";
ok( !$cmd_failed, "can open alternate log file" );
foreach my $msg ( qw/ TRACE DEBUG INFO WARN ERROR FATAL / ) {
$line = <LOG>;
ok ( $line =~ /\[$msg\] $msg \(main::/, "$msg logged" );
}
$line = <LOG>;
ok( $line =~ /\[FATAL\] FATAL \(main::/, "Changing log level works" );
$line = <LOG2>;
ok( $line =~ /\[DEBUG\] DEBUG2 \(main::/, "Alternate logger (one off) works" );
$line = <LOG>;
ok( $line =~ /\[DEBUG\] DEBUG \(main::/, "Logging to original logger (still) works" );
$line = <LOG2>;
ok( $line =~ /\[DEBUG\] DEBUG2 \(main::/, "Changing default logger works" );
close LOG;
close LOG2;
$cmd_failed = system ( "rm -f $logfile" );
ok( !$cmd_failed, "rm logfile $logfile" );
$cmd_failed = system ( "rm -f $logfile2" );
ok( !$cmd_failed, "rm logfile $logfile2" );
t/data/DB-test.yml view on Meta::CPAN
'Activator::Registry':
'Activator::DB':
# for testing config file Log4perl setup
# log4perl:
# 'log4perl.logger.Activator.DB' : 'WARN, Screen'
# 'log4perl.appender.Screen' : 'Log::Log4perl::Appender::Screen'
# 'log4perl.appender.Screen.layout' : 'Log::Log4perl::Layout::PatternLayout'
# 'log4perl.appender.Screen.layout.ConversionPattern' : 'YAML %d{yyyy-mm-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n'
default:
connection: test1_mysql
config:
debug: 0
debug_connection: 0
debug_attr: 0
connections:
test1_mysql:
user: act_db_test_user
t/data/Log-log4perl.conf view on Meta::CPAN
log4perl.logger.Activator.Log = WARN, LOGFILE
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/tmp/activator-log-test.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern = %d{yyyy-mm-dd HH:mm:ss.SSS} [%p] %m (%M %L)%n,