Class: MongoRequestLogger::Adapters::Base
- Inherits:
-
Object
- Object
- MongoRequestLogger::Adapters::Base
- Defined in:
- lib/mongo_request_logger/adapters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#authenticated ⇒ Object
readonly
Returns the value of attribute authenticated.
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#connection_type ⇒ Object
readonly
Returns the value of attribute connection_type.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
-
#capsize ⇒ Object
Capsize in bytes.
- #check_for_collection ⇒ Object
- #collection_name ⇒ Object
- #collection_stats_hash(stats) ⇒ Object
- #create_collection ⇒ Object
- #reconnect ⇒ Object
- #reset_collection ⇒ Object
Instance Attribute Details
#authenticated ⇒ Object (readonly)
Returns the value of attribute authenticated.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def authenticated @authenticated end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def collection @collection end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def connection @connection end |
#connection_type ⇒ Object (readonly)
Returns the value of attribute connection_type.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def connection_type @connection_type end |
Instance Method Details
#authenticated? ⇒ Boolean
18 19 20 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 18 def authenticated? @authenticated end |
#capsize ⇒ Object
Capsize in bytes
14 15 16 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 14 def capsize [:capsize] * 1024 * 1024 end |
#check_for_collection ⇒ Object
22 23 24 25 26 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 22 def check_for_collection # setup the capped collection if it doesn't already exist create_collection unless @connection.collection_names.include?(collection_name) @collection = @connection[collection_name] end |
#collection_name ⇒ Object
9 10 11 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 9 def collection_name [:collection] || 'server_log' end |
#collection_stats_hash(stats) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 39 def collection_stats_hash(stats) { :is_capped => (stats["capped"] && ([1, true].include?(stats["capped"]))), :count => stats["count"].to_i, :size => stats["size"].to_f, :storageSize => stats["storageSize"].to_f, :collection => collection_name } end |
#create_collection ⇒ Object
49 50 51 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 49 def create_collection raise "Not implemented" end |
#reconnect ⇒ Object
35 36 37 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 35 def reconnect end |
#reset_collection ⇒ Object
28 29 30 31 32 33 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 28 def reset_collection if @connection && @collection @collection.drop create_collection end end |