Class: Logster::BaseStore

Inherits:
Object
  • Object
show all
Defined in:
lib/logster/base_store.rb

Direct Known Subclasses

RedisStore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBaseStore

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

#ignoreObject

Returns the value of attribute ignore.



5
6
7
# File 'lib/logster/base_store.rb', line 5

def ignore
  @ignore
end

#levelObject

Returns the value of attribute level.



5
6
7
# File 'lib/logster/base_store.rb', line 5

def level
  @level
end

#max_retentionObject

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_emptyObject

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

#clearObject

Delete all unprotected messages in the store.



34
35
36
# File 'lib/logster/base_store.rb', line 34

def clear
  not_implemented
end

#clear_allObject

Delete all messages, including protected messages.



39
40
41
# File 'lib/logster/base_store.rb', line 39

def clear_all
  not_implemented
end

#countObject

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(message_key)
  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(message_key)
  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(message_key)
  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(message)
  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)

  message = 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

  message.populate_from_env(env)

  if backtrace
    if backtrace.respond_to? :join
      backtrace = backtrace.join("\n")
    end
    message.backtrace = backtrace
  else
    message.backtrace = caller.join("\n")
  end

  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
  end

  if similar
    similar.count += 1
    similar.merge_similar_message(message)

    replace_and_bump similar
    similar
  else
    save message
    message
  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(message)
  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(message)
  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(message_key)
  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(message_key)
  not_implemented
end