pg_audit_log 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -33,6 +33,8 @@ On a 2.93GHz i7 with postgresql 9.1 the audit log has an overhead of about 0.003
33
33
 
34
34
  The PgAuditLog::Entry ActiveRecord model represents a single entry in the audit log table. Each entry represents a single change to a single field of a record in a table. So if you change 3 columns of a record, that will generate 3 corresponding PgAuditLog::Entry records.
35
35
 
36
+ You can see the SQL it injects on every query by running with LOG_AUDIT_SQL
37
+
36
38
  === Migrations
37
39
 
38
40
  TODO
@@ -28,7 +28,7 @@ class PgAuditLog::Entry < ActiveRecord::Base
28
28
  INCREMENT BY 1;
29
29
 
30
30
  CREATE TABLE #{self.table_name} (
31
- id integer PRIMARY KEY DEFAULT nextval('#{self.table_name}_id_seq'),
31
+ id bigint PRIMARY KEY DEFAULT nextval('#{self.table_name}_id_seq'),
32
32
  user_id integer,
33
33
  user_unique_name character varying(255),
34
34
  operation character varying(255),
@@ -7,7 +7,8 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
7
7
  log_user_id = PgAuditLog::Function.user_identifier_temporary_function(user_id)
8
8
  log_user_unique_name = PgAuditLog::Function.user_unique_name_temporary_function(unique_name)
9
9
 
10
- log([log_user_id, log_user_unique_name, sql].join("; "), name) do
10
+ logged_sql = ENV["LOG_AUDIT_SQL"] ? [log_user_id, log_user_unique_name, sql].values.join('; ') : sql
11
+ log(logged_sql, name) do
11
12
  if @async
12
13
  @connection.async_exec(log_user_id)
13
14
  @connection.async_exec(log_user_unique_name)
@@ -11,7 +11,8 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
11
11
 
12
12
  def exec_query_with_auditing(sql, name = 'SQL', binds = [])
13
13
  audited_sql = generate_auditing_sql(sql)
14
- log(audited_sql.values.join("; "), name, binds) do
14
+ logged_sql = ENV["LOG_AUDIT_SQL"] ? audited_sql.values.join('; ') : sql
15
+ log(logged_sql, name, binds) do
15
16
  exec_no_cache(audited_sql[:user_id], binds)
16
17
  exec_no_cache(audited_sql[:unique_name], binds)
17
18
  result = binds.empty? ? exec_no_cache(sql, binds) :
@@ -31,6 +31,7 @@ module PgAuditLog
31
31
  END
32
32
  $_$;
33
33
  SQL
34
+ sql.split("\n").join(" ")
34
35
  end
35
36
 
36
37
  def user_unique_name_temporary_function(username)
@@ -43,6 +44,7 @@ module PgAuditLog
43
44
  END
44
45
  $_$;
45
46
  SQL
47
+ sql.split("\n").join(" ")
46
48
  end
47
49
 
48
50
  def install
@@ -1,3 +1,3 @@
1
1
  module PgAuditLog
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_audit_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-09 00:00:00.000000000Z
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70094371058580 !ruby/object:Gem::Requirement
16
+ requirement: &70252020501060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70094371058580
24
+ version_requirements: *70252020501060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: pg
27
- requirement: &70094371056820 !ruby/object:Gem::Requirement
27
+ requirement: &70252020500560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70094371056820
35
+ version_requirements: *70252020500560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-rails
38
- requirement: &70094371056040 !ruby/object:Gem::Requirement
38
+ requirement: &70252020500100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.7'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70094371056040
46
+ version_requirements: *70252020500100
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: with_model
49
- requirement: &70094371055100 !ruby/object:Gem::Requirement
49
+ requirement: &70252020499640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.1.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70094371055100
57
+ version_requirements: *70252020499640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: autotest
60
- requirement: &70094371054000 !ruby/object:Gem::Requirement
60
+ requirement: &70252020499260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70094371054000
68
+ version_requirements: *70252020499260
69
69
  description: A completely transparent audit logging component for your application
70
70
  using a stored procedure and triggers. Comes with specs for your project and a rake
71
71
  task to generate the reverse SQL to undo changes logged
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -4309702284919187778
123
+ hash: 3581204670683200493
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
@@ -129,10 +129,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  segments:
131
131
  - 0
132
- hash: -4309702284919187778
132
+ hash: 3581204670683200493
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 1.8.6
135
+ rubygems_version: 1.8.15
136
136
  signing_key:
137
137
  specification_version: 3
138
138
  summary: postgresql only database-level audit logging of all databases changes