ixtlan-audit 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,8 +39,7 @@ module Ixtlan
39
39
 
40
40
  def self.included( base )
41
41
  base.prepend_aspect :audit
42
- manager = Manager.new
43
- base[ :audit_manager ] = manager
42
+ manager = base[ :audit_manager ] ||= Manager.new
44
43
  base.use( Rack, manager)
45
44
  end
46
45
  end
@@ -46,7 +46,7 @@ module Ixtlan
46
46
 
47
47
  public
48
48
 
49
- attr_accessor :model, :block, :keep_logs
49
+ attr_accessor :model, :block, :keep_logs, :dump_to_console
50
50
 
51
51
  def initialize( model = nil, &block )
52
52
  @model = model
@@ -71,13 +71,19 @@ module Ixtlan
71
71
  end
72
72
  @keep_logs
73
73
  end
74
-
74
+
75
+ def dump_to_console
76
+ keep_logs == 0
77
+ end
78
+
75
79
  def push( username, http_method, path, obj, user = nil )
76
80
  if model
77
- message =
78
- if !obj.is_a?( String ) && obj.respond_to?( :collect )
81
+ message =
82
+ if obj.respond_to?( :errors ) && obj.errors.size > 0
83
+ "#{obj.class} - errors: " + obj.errors.collect{ |e| e }.join( '. ' )
84
+ elsif !obj.is_a?( String ) && obj.respond_to?( :collect )
79
85
  if o = obj.first
80
- "#{o.class}[ #{obj.size} ]"
86
+ "#{o.class} - size: #{obj.size}"
81
87
  else
82
88
  "[ 0 ] - <EMPTY ARRAY>"
83
89
  end
@@ -90,6 +96,7 @@ module Ixtlan
90
96
  :login => username || '???' )
91
97
  m.created_by = user if user && m.respond_to?( :created_by ) && user.respond_to?( :new? ) && !user.new?
92
98
  list << m
99
+ logger.info( "[#{username}] #{http_method} #{path} #{message}" ) if dump_to_console
93
100
  end
94
101
  list.last
95
102
  end
@@ -24,7 +24,7 @@ module Ixtlan
24
24
  class Audit
25
25
  include DataMapper::Resource
26
26
 
27
- def self.storage_name(arg)
27
+ def self.storage_name( arg = :default )
28
28
  'ixtlan_audits'
29
29
  end
30
30
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ixtlan-audit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.1
5
+ version: 0.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Meier
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slf4r
@@ -115,25 +115,25 @@ extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
117
  - MIT-LICENSE
118
- - lib/ixtlan-audit.rb~
119
118
  - lib/ixtlan-audit.rb
120
- - lib/ixtlan/audit/cuba.rb~
121
- - lib/ixtlan/audit/cuba_plugin.rb
122
- - lib/ixtlan/audit/cuba.rb
123
- - lib/ixtlan/audit/resource.rb
124
- - lib/ixtlan/audit/cuba_setup.rb~
119
+ - lib/ixtlan-audit.rb~
125
120
  - lib/ixtlan/audit/logging_configurator.rb~
126
- - lib/ixtlan/audit/user_logger.rb
127
- - lib/ixtlan/audit/audit_resource.rb~
121
+ - lib/ixtlan/audit/cuba_plugin.rb~
128
122
  - lib/ixtlan/audit/manager.rb
123
+ - lib/ixtlan/audit/rack.rb
124
+ - lib/ixtlan/audit/resource.rb
125
+ - lib/ixtlan/audit/rack.rb~
129
126
  - lib/ixtlan/audit/audit_serializer.rb~
130
- - lib/ixtlan/audit/manager.rb~
131
127
  - lib/ixtlan/audit/railtie.rb
132
- - lib/ixtlan/audit/user_logger.rb~
133
- - lib/ixtlan/audit/rack.rb~
134
- - lib/ixtlan/audit/rack.rb
135
- - lib/ixtlan/audit/cuba_plugin.rb~
128
+ - lib/ixtlan/audit/manager.rb~
129
+ - lib/ixtlan/audit/cuba_setup.rb~
130
+ - lib/ixtlan/audit/cuba.rb
131
+ - lib/ixtlan/audit/cuba_plugin.rb
136
132
  - lib/ixtlan/audit/serializer.rb
133
+ - lib/ixtlan/audit/user_logger.rb
134
+ - lib/ixtlan/audit/audit_resource.rb~
135
+ - lib/ixtlan/audit/user_logger.rb~
136
+ - lib/ixtlan/audit/cuba.rb~
137
137
  - spec/audit_manager_spec.rb
138
138
  - spec/audit_manager_spec.rb~
139
139
  homepage: http://github.com/mkristian/ixtlan-audit