lib/logster/base_store.rb in logster-1.4.0.pre vs lib/logster/base_store.rb in logster-2.0.0.pre
- old
+ new
@@ -12,11 +12,11 @@
def save(message)
not_implemented
end
# Modify the saved message to the given one (identified by message.key) and bump it to the top of the latest list
- def replace_and_bump(message)
+ def replace_and_bump(message, save_env: true)
not_implemented
end
# Check if another message with the same grouping_key is already stored.
# Returns the similar message's message.key
@@ -38,14 +38,24 @@
def clear_all
not_implemented
end
# Get a message by its message_key
- def get(message_key)
+ def get(message_key, load_env: true)
not_implemented
end
+ # Get a group of messages by their message_keys
+ def bulk_get(message_keys)
+ not_implemented
+ end
+
+ # Get a message's env by its message_key
+ def get_env(message_key)
+ not_implemented
+ end
+
# Mark a message as protected; i.e. it is not deleted by the #clear method
def protect(message_key)
not_implemented
end
@@ -96,22 +106,26 @@
message.backtrace = backtrace
else
message.backtrace = caller.join("\n")
end
- return if ignore && ignore.any? { |pattern| message =~ pattern}
+ return if ignore && ignore.any? { |pattern| message =~ pattern }
similar = nil
if Logster.config.allow_grouping
key = self.similar_key(message)
- similar = get key if key
+ similar = get(key, load_env: false) if key
end
if similar
- similar.merge_similar_message(message)
+ has_env = !similar.env.nil? && !similar.env.empty?
+ if similar.count < Logster::MAX_GROUPING_LENGTH && !has_env
+ similar.env = get_env(similar.key) || {}
+ end
+ save_env = similar.merge_similar_message(message)
- replace_and_bump similar
+ replace_and_bump(similar, save_env: save_env || has_env)
similar
else
save message
message
end