prisma 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ require 'redis-namespace'
4
4
  require 'prisma/group'
5
5
  require 'prisma/railtie'
6
6
  require 'prisma/filter'
7
+ require 'prisma/null_logger'
7
8
 
8
9
  # Used for configuration, typically in a Rails initializer.
9
10
  module Prisma
@@ -29,6 +30,12 @@ module Prisma
29
30
  # @!visibility private
30
31
  @@redis_namespace = 'prisma'
31
32
 
33
+ # @!visibility public
34
+ # Logger instance responding to +debug+, +warn+ and +error+.
35
+ mattr_accessor :logger
36
+ # @!visibility private
37
+ @@logger = NullLogger.new
38
+
32
39
  # @!visibility public
33
40
  # Duration in seconds for expiring redis keys (easy to use with Rails duration helpers +1.day+)
34
41
  mattr_accessor :redis_expiration_duration
@@ -39,6 +46,7 @@ module Prisma
39
46
  # config.redis = Redis.new(db: 1)
40
47
  # config.redis_namespace = 'stats'
41
48
  # config.redis_expiration_duration = 2.days
49
+ # config.logger = Rails.logger
42
50
  # end
43
51
  def self.setup
44
52
  yield self
@@ -25,6 +25,9 @@ module Prisma
25
25
  end
26
26
  Prisma.redis.expire redis_key, Prisma.redis_expire if Prisma.redis_expiration_duration
27
27
  end
28
+ rescue => e
29
+ Prisma.logger.error "Prisma experienced an exception: #{e.to_s}"
30
+ Prisma.logger.error e.backtrace.join("\n")
28
31
  end
29
32
  end
30
33
  end
@@ -0,0 +1,9 @@
1
+ module Prisma
2
+ # Default logger which acts like a black hole
3
+ class NullLogger
4
+ # Responds to everything, does nothing and returns nil
5
+ def method_missing(method, *args, &block)
6
+ end
7
+ end
8
+ end
9
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prisma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -312,6 +312,7 @@ files:
312
312
  - lib/prisma.rb
313
313
  - lib/prisma/filter.rb
314
314
  - lib/prisma/group.rb
315
+ - lib/prisma/null_logger.rb
315
316
  - lib/prisma/railtie.rb
316
317
  - lib/prisma/server.rb
317
318
  - lib/prisma/server/public/bootstrap-responsive.min.css
@@ -336,7 +337,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
337
  version: '0'
337
338
  segments:
338
339
  - 0
339
- hash: -3103978242459801241
340
+ hash: -4548465822785429403
340
341
  required_rubygems_version: !ruby/object:Gem::Requirement
341
342
  none: false
342
343
  requirements: