Permalink
Browse files

Show database:schema for each debug statement.

  • Loading branch information...
1 parent ad47f32 commit e4d96ad7e3a5b288af05bfd3eb2e0203a32e6e51 @wayneeseguin committed Apr 27, 2012
Showing with 12 additions and 12 deletions.
  1. +6 −6 lib/psql-cm/base.rb
  2. +6 −6 lib/psql-cm/restore.rb
View
@@ -1,15 +1,15 @@
module PSQLCM
class << self
- def verbose(message)
- $stdout.puts message if (config.verbose || config.debug)
+ def verbose(*message)
+ $stdout.puts message.join(' ') if (config.verbose || config.debug)
end
- def debug(message)
- $stdout.puts message if config.debug
+ def debug(*message)
+ $stdout.puts message.join(' ') if config.debug
end
- def halt!(message)
- $stderr.puts message
+ def halt!(*message)
+ $stderr.puts message.join(' ')
exit 1
end
View
@@ -28,7 +28,8 @@ def restore!
end
begin
- debug "restore> #{database}:#{schema} < #{cm_file}"
+ tag = "restore:#{database}:#{schema}>"
+ debug tag, cm_file
sh "psql #{db(database).psql_args} #{database} < #{cm_file}"
ensure_cm_table_exists(database,schema)
@@ -37,17 +38,17 @@ def restore!
WHERE is_base = $1 ORDER BY created_at ASC;"
Tempfile.open('base.sql') do |temp_file|
- debug "restore:base:sql> #{sql.sub('$1','true')}"
+ debug tag, "base:sql> #{sql.sub('$1','true')}"
row = db(database).exec(sql, ['true'])
temp_file.write(row)
sh "psql #{db(database).psql_args} #{database} < #{temp_file.path}"
end
- debug "restore:changes:sql> #{sql.sub('$1','false')}"
+ debug tag, "changes:sql> #{sql.sub('$1','false')}"
changes = db(database).exec(sql,['false'])
- debug "restore:change:count>#{changes.cmd_tuples}"
+ debug tag, "change:count>#{changes.cmd_tuples}"
changes.each do |row|
- debug "restore:change:content>\n#{row['content']}"
+ debug tag, "content>\n#{row['content']}"
Tempfile.open('change.sql') do |temp_file|
temp_file.write(row['content'])
temp_file.close
@@ -60,7 +61,6 @@ def restore!
file.write psqlrc
end
end
-
end
end
end

0 comments on commit e4d96ad

Please sign in to comment.