From: Arthur Axel 'fREW' Schmidt Date: Sun, 30 May 2010 00:47:23 +0000 (-0500) Subject: logger automatically prepends [DBICDH] now X-Git-Tag: v0.001000_13~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f407579197b3d54de98e487bfa1a978c23aade6a;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git logger automatically prepends [DBICDH] now --- diff --git a/lib/DBIx/Class/DeploymentHandler/Dad.pm b/lib/DBIx/Class/DeploymentHandler/Dad.pm index aedd707..b65fabf 100644 --- a/lib/DBIx/Class/DeploymentHandler/Dad.pm +++ b/lib/DBIx/Class/DeploymentHandler/Dad.pm @@ -41,7 +41,7 @@ has schema_version => ( sub _build_schema_version { $_[0]->schema->schema_version } method install { - log_info { '[DBICDH] installing version ' . $self->to_version }; + log_info { 'installing version ' . $self->to_version }; croak 'Install not possible as versions table already exists in database' if $self->version_storage_is_installed; @@ -54,7 +54,7 @@ method install { } sub upgrade { - log_info { '[DBICDH] upgrading' }; + log_info { 'upgrading' }; my $self = shift; my $ran_once = 0; while ( my $version_list = $self->next_version_set ) { @@ -70,11 +70,11 @@ sub upgrade { }); } - log_warn { '[DBICDH] no need to run upgrade' } unless $ran_once; + log_warn { 'no need to run upgrade' } unless $ran_once; } sub downgrade { - log_info { '[DBICDH] upgrading' }; + log_info { 'upgrading' }; my $self = shift; my $ran_once = 0; while ( my $version_list = $self->previous_version_set ) { @@ -84,11 +84,11 @@ sub downgrade { # do we just delete a row here? I think so but not sure $self->delete_database_version({ version => $version_list->[-1] }); } - log_warn { '[DBICDH] no version to run downgrade' } unless $ran_once; + log_warn { 'no version to run downgrade' } unless $ran_once; } method backup { - log_info { '[DBICDH] backing up' }; + log_info { 'backing up' }; $self->storage->backup($self->backup_directory) } diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index b6e78a3..094457c 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -170,7 +170,7 @@ method _run_sql_array($sql) { join '', grep { !/^--/ } split /\n/ # remove comments } @$sql]; - Dlog_trace { "[DBICDH] Running SQL $_" } $sql; + Dlog_trace { "Running SQL $_" } $sql; foreach my $line (@{$sql}) { $storage->_query_start($line); # the whole reason we do this is so that we can see the line that was run @@ -186,18 +186,18 @@ method _run_sql_array($sql) { } method _run_sql($filename) { - log_debug { "[DBICDH] Running SQL from $filename" }; + log_debug { "Running SQL from $filename" }; return $self->_run_sql_array($self->_read_sql_file($filename)); } method _run_perl($filename) { - log_debug { "[DBICDH] Running Perl from $filename" }; + log_debug { "Running Perl from $filename" }; my $filedata = do { local( @ARGV, $/ ) = $filename; <> }; no warnings 'redefine'; my $fn = eval "$filedata"; use warnings; - Dlog_trace { "[DBICDH] Running Perl $_" } $fn; + Dlog_trace { "Running Perl $_" } $fn; if ($@) { carp "$filename failed to compile: $@"; @@ -243,7 +243,7 @@ method _run_sql_and_perl($filenames) { sub deploy { my $self = shift; my $version = (shift @_ || {})->{version} || $self->schema_version; - log_info { "[DBICDH] deploying version $version" }; + log_info { "deploying version $version" }; return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames( $self->storage->sqlt_type, @@ -255,7 +255,7 @@ sub preinstall { my $self = shift; my $args = shift; my $version = $args->{version} || $self->schema_version; - log_info { "[DBICDH] preinstalling version $version" }; + log_info { "preinstalling version $version" }; my $storage_type = $args->{storage_type} || $self->storage->sqlt_type; my @files = @{$self->_ddl_preinstall_consume_filenames( @@ -348,7 +348,7 @@ sub install_resultsource { my ($self, $args) = @_; my $source = $args->{result_source}; my $version = $args->{version}; - log_info { '[DBICDH] installing_resultsource ' . $source->source_name . ", version $version" }; + log_info { 'installing_resultsource ' . $source->source_name . ", version $version" }; my $rs_install_file = $self->_resultsource_install_filename($source->source_name); @@ -364,7 +364,7 @@ sub install_resultsource { sub prepare_resultsource_install { my $self = shift; my $source = (shift @_)->{result_source}; - log_info { '[DBICDH] preparing install for resultsource ' . $source->source_name }; + log_info { 'preparing install for resultsource ' . $source->source_name }; my $filename = $self->_resultsource_install_filename($source->source_name); $self->_prepare_install({ @@ -373,7 +373,7 @@ sub prepare_resultsource_install { } sub prepare_deploy { - log_info { '[DBICDH] preparing deploy' }; + log_info { 'preparing deploy' }; my $self = shift; $self->_prepare_install({}, '_ddl_schema_produce_filename'); } @@ -381,8 +381,7 @@ sub prepare_deploy { sub prepare_upgrade { my ($self, $args) = @_; log_info { - '[DBICDH] preparing upgrade ' . - "from $args->{from_version} to $args->{to_version}" + "preparing upgrade from $args->{from_version} to $args->{to_version}" }; $self->_prepare_changegrade( $args->{from_version}, $args->{to_version}, $args->{version_set}, 'up' @@ -392,8 +391,7 @@ sub prepare_upgrade { sub prepare_downgrade { my ($self, $args) = @_; log_info { - '[DBICDH] preparing downgrade ' . - "from $args->{from_version} to $args->{to_version}" + "preparing downgrade from $args->{from_version} to $args->{to_version}" }; $self->_prepare_changegrade( $args->{from_version}, $args->{to_version}, $args->{version_set}, 'down' @@ -522,7 +520,7 @@ method _default_read_sql_file_as_string($file) { sub downgrade_single_step { my $self = shift; my $version_set = (shift @_)->{version_set}; - Dlog_info { qq([DBICDH] downgrade_single_step'ing $_) } $version_set; + Dlog_info { "downgrade_single_step'ing $_" } $version_set; my $sql = $self->_run_sql_and_perl($self->_ddl_schema_down_consume_filenames( $self->storage->sqlt_type, @@ -535,7 +533,7 @@ sub downgrade_single_step { sub upgrade_single_step { my $self = shift; my $version_set = (shift @_)->{version_set}; - Dlog_info { qq([DBICDH] upgrade_single_step'ing $_) } $version_set; + Dlog_info { "upgrade_single_step'ing $_" } $version_set; my $sql = $self->_run_sql_and_perl($self->_ddl_schema_up_consume_filenames( $self->storage->sqlt_type, diff --git a/lib/DBIx/Class/DeploymentHandler/Logger.pm b/lib/DBIx/Class/DeploymentHandler/Logger.pm index 8112717..565a898 100644 --- a/lib/DBIx/Class/DeploymentHandler/Logger.pm +++ b/lib/DBIx/Class/DeploymentHandler/Logger.pm @@ -29,4 +29,12 @@ sub is_fatal { return $_[0]->is_error || 1 } +sub _log { + my $self = shift; + my $level = shift; + my $message = join( "\n", @_ ); + $message .= "\n" unless $message =~ /\n$/; + warn "[DBICDH] [$level] $message"; +} + 1; diff --git a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm index ca17fbc..0e6471e 100644 --- a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm @@ -38,13 +38,13 @@ sub _build_version_rs { sub add_database_version { # deprecated doesn't support ddl or upgrade_ddl my $version = $_[1]->{version}; - log_debug { "[DBICDH] Adding database version $version" }; + log_debug { "Adding database version $version" }; $_[0]->version_rs->create({ version => $version }) } sub delete_database_version { my $version = $_[1]->{version}; - log_debug { "[DBICDH] Deleting database version $version" }; + log_debug { "Deleting database version $version" }; $_[0]->version_rs->search({ version => $version})->delete } diff --git a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm index bfc4307..4567812 100644 --- a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm +++ b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm @@ -36,13 +36,13 @@ sub _build_version_rs { sub add_database_version { my $version = $_[1]->{version}; - log_debug { "[DBICDH] Adding database version $version" }; + log_debug { "Adding database version $version" }; $_[0]->version_rs->create($_[1]) } sub delete_database_version { my $version = $_[1]->{version}; - log_debug { "[DBICDH] Deleting database version $version" }; + log_debug { "Deleting database version $version" }; $_[0]->version_rs->search({ version => $version})->delete }