Class: Logster::BaseStore
- Inherits:
-
Object
- Object
- Logster::BaseStore
- Defined in:
- lib/logster/base_store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ignore ⇒ Object
Returns the value of attribute ignore.
-
#level ⇒ Object
Returns the value of attribute level.
-
#max_retention ⇒ Object
Returns the value of attribute max_retention.
-
#skip_empty ⇒ Object
Returns the value of attribute skip_empty.
Instance Method Summary collapse
-
#check_rate_limits(severity) ⇒ Object
Checks all the existing rate limiters to check if any has been exceeded.
-
#clear ⇒ Object
Delete all unprotected messages in the store.
-
#clear_all ⇒ Object
Delete all messages, including protected messages.
-
#count ⇒ Object
The number of messages currently stored.
- #delete(message_key) ⇒ Object
-
#get(message_key) ⇒ Object
Get a message by its message_key.
-
#initialize ⇒ BaseStore
constructor
A new instance of BaseStore.
-
#protect(message_key) ⇒ Object
Mark a message as protected; i.e.
-
#register_rate_limit(severities, limit, duration, &block) ⇒ Object
Registers a rate limit on the given severities of logs.
-
#replace_and_bump(message) ⇒ Object
Modify the saved message to the given one (identified by message.key) and bump it to the top of the latest list.
- #report(severity, progname, msg, opts = {}) ⇒ Object
-
#save(message) ⇒ Object
Save a new message at the front of the latest list.
-
#similar_key(message) ⇒ Object
Check if another message with the same grouping_key is already stored.
-
#solve(message_key) ⇒ Object
Solve a particular message, causing all old messages with matching version and backtrace to be deleted (report should delete any solved messages when called).
-
#unprotect(message_key) ⇒ Object
Clear the protected mark for a message.
Constructor Details
#initialize ⇒ BaseStore
Returns a new instance of BaseStore.
7 8 9 10 |
# File 'lib/logster/base_store.rb', line 7 def initialize @max_retention = 60 * 60 * 24 * 7 @skip_empty = true end |
Instance Attribute Details
#ignore ⇒ Object
Returns the value of attribute ignore.
5 6 7 |
# File 'lib/logster/base_store.rb', line 5 def ignore @ignore end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/logster/base_store.rb', line 5 def level @level end |
#max_retention ⇒ Object
Returns the value of attribute max_retention.
5 6 7 |
# File 'lib/logster/base_store.rb', line 5 def max_retention @max_retention end |
#skip_empty ⇒ Object
Returns the value of attribute skip_empty.
5 6 7 |
# File 'lib/logster/base_store.rb', line 5 def skip_empty @skip_empty end |
Instance Method Details
#check_rate_limits(severity) ⇒ Object
Checks all the existing rate limiters to check if any has been exceeded
74 75 76 |
# File 'lib/logster/base_store.rb', line 74 def check_rate_limits(severity) not_implemented end |
#clear ⇒ Object
Delete all unprotected messages in the store.
34 35 36 |
# File 'lib/logster/base_store.rb', line 34 def clear not_implemented end |
#clear_all ⇒ Object
Delete all messages, including protected messages.
39 40 41 |
# File 'lib/logster/base_store.rb', line 39 def clear_all not_implemented end |
#count ⇒ Object
The number of messages currently stored.
29 30 31 |
# File 'lib/logster/base_store.rb', line 29 def count not_implemented end |
#delete(message_key) ⇒ Object
53 54 55 |
# File 'lib/logster/base_store.rb', line 53 def delete() not_implemented end |
#get(message_key) ⇒ Object
Get a message by its message_key
44 45 46 |
# File 'lib/logster/base_store.rb', line 44 def get() not_implemented end |
#protect(message_key) ⇒ Object
Mark a message as protected; i.e. it is not deleted by the #clear method
49 50 51 |
# File 'lib/logster/base_store.rb', line 49 def protect() not_implemented end |
#register_rate_limit(severities, limit, duration, &block) ⇒ Object
Registers a rate limit on the given severities of logs
69 70 71 |
# File 'lib/logster/base_store.rb', line 69 def register_rate_limit(severities, limit, duration, &block) not_implemented end |
#replace_and_bump(message) ⇒ Object
Modify the saved message to the given one (identified by message.key) and bump it to the top of the latest list
18 19 20 |
# File 'lib/logster/base_store.rb', line 18 def replace_and_bump() not_implemented end |
#report(severity, progname, msg, opts = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/logster/base_store.rb', line 78 def report(severity, progname, msg, opts = {}) return if (!msg || (String === msg && msg.empty?)) && skip_empty return if level && severity < level check_rate_limits(severity) = Logster::Message.new(severity, progname, msg, opts[:timestamp]) env = opts[:env] || {} backtrace = opts[:backtrace] if env[:backtrace] # Special - passing backtrace through env backtrace = env.delete(:backtrace) end .populate_from_env(env) if backtrace if backtrace.respond_to? :join backtrace = backtrace.join("\n") end .backtrace = backtrace else .backtrace = caller.join("\n") end return if ignore && ignore.any? { |pattern| =~ pattern} similar = nil if Logster.config.allow_grouping key = self.similar_key() similar = get key if key end if similar similar.count += 1 similar.() replace_and_bump similar similar else save end end |
#save(message) ⇒ Object
Save a new message at the front of the latest list.
13 14 15 |
# File 'lib/logster/base_store.rb', line 13 def save() not_implemented end |
#similar_key(message) ⇒ Object
Check if another message with the same grouping_key is already stored. Returns the similar message’s message.key
24 25 26 |
# File 'lib/logster/base_store.rb', line 24 def similar_key() not_implemented end |
#solve(message_key) ⇒ Object
Solve a particular message, causing all old messages with matching version and backtrace to be deleted (report should delete any solved messages when called)
64 65 66 |
# File 'lib/logster/base_store.rb', line 64 def solve() not_implemented end |
#unprotect(message_key) ⇒ Object
Clear the protected mark for a message.
58 59 60 |
# File 'lib/logster/base_store.rb', line 58 def unprotect() not_implemented end |