Class: CrashLog::Configuration
- Inherits:
-
Hashr
- Object
- Hashr
- CrashLog::Configuration
- Defined in:
- lib/crash_log/configuration.rb
Constant Summary collapse
- DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
- DEFAULT_USER_ATTRIBUTES =
%w(id name full_name username email created_at).freeze
- DEFAULT_BACKTRACE_FILTERS =
[ lambda { |line| if defined?(CrashLog.configuration.root) && CrashLog.configuration.root.to_s != '' && line line.sub(/#{CrashLog.configuration.root}/, "[PROJECT_ROOT]") else line end }, lambda { |line| line && line.gsub(/^\.\//, "") }, lambda { |line| if defined?(Gem) && line Gem.path.inject(line) do |line, path| line.gsub(/#{path}/, "[GEM_ROOT]") end end }, lambda { |line| line if line && line !~ %r{lib/crash_log} } ].freeze
- IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound', 'ActionController::RoutingError', 'ActionController::InvalidAuthenticityToken', 'CGI::Session::CookieStore::TamperedWithCookie', 'ActionController::UnknownAction', 'AbstractController::ActionNotFound', 'Mongoid::Errors::DocumentNotFound']
- ENVIRONMENT_FILTERS_DEFAULT =
[ /SECRET/, /AWS/, /PASSWORD/, /PRIVATE/, /EC2/, /HEROKU/ ]
Instance Method Summary collapse
- #ca_bundle_path ⇒ Object
-
#development_mode=(flag) ⇒ Object
Helps to enable debug logging when in development mode.
- #development_mode? ⇒ Boolean
- #ignored?(exception) ⇒ Boolean
- #invalid_keys ⇒ Object
- #local_cert_path ⇒ Object
- #logger=(new_logger) ⇒ Object
- #notifier_version ⇒ Object
- #port ⇒ Object
-
#release_stage? ⇒ Boolean
Release stages are stages which send exceptions.
- #root ⇒ Object
- #root=(string) ⇒ Object
- #secure? ⇒ Boolean
-
#stage=(name) ⇒ Object
Set the current stage.
-
#valid? ⇒ Boolean
Is this configuration valid for sending exceptions to CrashLog.
Instance Method Details
#ca_bundle_path ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/crash_log/configuration.rb', line 223 def ca_bundle_path if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE) OpenSSL::X509::DEFAULT_CERT_FILE else local_cert_path # ca-bundle.crt built from source, see resources/README.md end end |
#development_mode=(flag) ⇒ Object
Helps to enable debug logging when in development mode
241 242 243 244 245 246 247 |
# File 'lib/crash_log/configuration.rb', line 241 def development_mode=(flag) self[:development_mode] = flag self.level = Logger::DEBUG if new_logger new_logger.level = self.level if self.logger.respond_to?(:level=) end end |
#development_mode? ⇒ Boolean
219 220 221 |
# File 'lib/crash_log/configuration.rb', line 219 def development_mode? development_mode.eql?(true) end |
#ignored?(exception) ⇒ Boolean
207 208 209 |
# File 'lib/crash_log/configuration.rb', line 207 def ignored?(exception) ignore.include?(error_class(exception).to_s) end |
#invalid_keys ⇒ Object
201 202 203 204 205 |
# File 'lib/crash_log/configuration.rb', line 201 def invalid_keys [:api_key, :secret, :host, :port].map do |key| key if send(key).nil? end.compact end |
#local_cert_path ⇒ Object
231 232 233 |
# File 'lib/crash_log/configuration.rb', line 231 def local_cert_path File.(File.join("../../../resources/ca-bundle.crt"), __FILE__) end |
#logger=(new_logger) ⇒ Object
235 236 237 238 |
# File 'lib/crash_log/configuration.rb', line 235 def logger=(new_logger) self[:logger] = new_logger new_logger.level = self.level if self.logger.respond_to?(:level=) end |
#notifier_version ⇒ Object
215 216 217 |
# File 'lib/crash_log/configuration.rb', line 215 def notifier_version CrashLog::VERSION end |
#port ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/crash_log/configuration.rb', line 176 def port if secure? 443 else fetch(:port, 80) end end |
#release_stage? ⇒ Boolean
Release stages are stages which send exceptions
185 186 187 |
# File 'lib/crash_log/configuration.rb', line 185 def release_stage? Array(release_stages).include?(stage) end |
#root ⇒ Object
168 169 170 |
# File 'lib/crash_log/configuration.rb', line 168 def root fetch(:project_root) end |
#root=(string) ⇒ Object
172 173 174 |
# File 'lib/crash_log/configuration.rb', line 172 def root=(string) self[:project_root] = string end |
#secure? ⇒ Boolean
211 212 213 |
# File 'lib/crash_log/configuration.rb', line 211 def secure? fetch(:scheme, 'https') == 'https' end |
#stage=(name) ⇒ Object
Set the current stage
190 191 192 |
# File 'lib/crash_log/configuration.rb', line 190 def stage=(name) self[:stage] = name.downcase.strip end |
#valid? ⇒ Boolean
Is this configuration valid for sending exceptions to CrashLog
Returns true if all required keys are provided, otherwise false
197 198 199 |
# File 'lib/crash_log/configuration.rb', line 197 def valid? invalid_keys.empty? end |