lib/semantic_logger/appender/mongodb.rb in semantic_logger-2.15.0 vs lib/semantic_logger/appender/mongodb.rb in semantic_logger-2.16.0
- old
+ new
@@ -33,11 +33,11 @@
attr_reader :db, :collection_name, :collection
attr_accessor :host_name, :write_concern, :application
# Create a MongoDB Appender instance
#
- # SemanticLogger::Appender::MongoDB.new(:db => Mongo::Connection.new['database'])
+ # SemanticLogger::Appender::MongoDB.new(db: Mongo::Connection.new['database'])
#
# Parameters:
# :db [Mongo::Database]
# The MongoDB database connection to use, not the database name
#
@@ -114,11 +114,11 @@
# * Documents are always stored in insertion order
# * A find will always return the documents in their insertion order
#
# Creates an index based on tags to support faster lookups
def create_indexes
- options = {:capped => true, :size => @collection_size}
+ options = {capped: true, size: @collection_size}
options[:max] = @collection_max if @collection_max
db.create_collection(collection_name, options)
db[@collection_name].ensure_index('tags')
end
@@ -139,28 +139,28 @@
# Default log formatter
# Replace this formatter by supplying a Block to the initializer
def default_formatter
Proc.new do |log|
- document = {
- :time => log.time,
- :host_name => host_name,
- :pid => $$,
- :thread_name => log.thread_name,
- :name => log.name,
- :level => log.level,
- :level_index => log.level_index,
+ document = {
+ time: log.time,
+ host_name: host_name,
+ pid: $$,
+ thread_name: log.thread_name,
+ name: log.name,
+ level: log.level,
+ level_index: log.level_index,
}
document[:application] = application if application
document[:message] = self.class.strip_colorizing(log.message) if log.message
document[:duration] = log.duration if log.duration
document[:tags] = log.tags if log.tags && (log.tags.size > 0)
document[:payload] = log.payload if log.payload
document[:exception] = {
- :name => log.exception.class.name,
- :message => log.exception.message,
- :stack_trace => log.exception.backtrace
+ name: log.exception.class.name,
+ message: log.exception.message,
+ stack_trace: log.exception.backtrace
} if log.exception
document
end
end
@@ -189,6 +189,6 @@
true
end
end
end
-end
\ No newline at end of file
+end