Class: ErrorStalker::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/error_stalker/server.rb

Overview

The ErrorStalker server. Provides a UI for browsing, grouping, and searching exception reports, as well as a centralized store for keeping exception reports. As a Sinatra app, this can be run using a config.ru file or something like Vegas. A sample Vegas runner for the server is located in bin/error_stalker_server.

Constant Summary collapse

PER_PAGE =

The number of exceptions or exception groups to show on each page.

25

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServer

Creates a new instance of the server, based on the configuration contained in the configuration attribute.



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/error_stalker/server.rb', line 89

def initialize
  super
  self.plugins = []
  if configuration['plugin']
    configuration['plugin'].each do |config|
      plugin_class = config['class'].split('::').inject(Object) {|mod, string| mod.const_get(string)}
      self.plugins << plugin_class.new(self, config['parameters'])
    end
  end
  self.store = self.class.store
end

Class Attribute Details

.configurationObject

A hash of configuration options, usually read from a configuration file.



63
64
65
# File 'lib/error_stalker/server.rb', line 63

def configuration
  @configuration
end

Instance Attribute Details

#pluginsObject

A list of plugins the server will use.



28
29
30
# File 'lib/error_stalker/server.rb', line 28

def plugins
  @plugins
end

#storeObject

The data store (ErrorStalker::Store instance) to use to store exception data



25
26
27
# File 'lib/error_stalker/server.rb', line 25

def store
  @store
end

Class Method Details

.storeObject

The default ErrorStalker::Store subclass to use by default for this ErrorStalker::Server instance. This is defined as a class method as well as an instance method so that it can be set by a configuration file before rack creates the instance of this sinatra app.



72
73
74
75
76
77
78
79
# File 'lib/error_stalker/server.rb', line 72

def self.store
  if configuration['store']
    store_class = configuration['store']['class'].split('::').inject(Object) {|mod, string| mod.const_get(string)}
    store_class.new(*Array(configuration['store']['parameters']))
  else
    ErrorStalker::Store::InMemory.new
  end
end

Instance Method Details

#configurationObject

A hash of configuration options, usually read from a configuration file.



83
84
85
# File 'lib/error_stalker/server.rb', line 83

def configuration
  self.class.configuration
end