Commit 81dc85c061ecd913c4f688defc9d97806b90ad26
1 parent
bdf4aa57
Exists in
master
and in
1 other branch
log to STDOUT by default
inspired by 12-factor, we now log to STDOUT by default instead of a named log file in ./log. This is just a default, and you can still configure your own log location using ERRBIT_LOG_LOCATION.
Showing
8 changed files
with
23 additions
and
7 deletions
Show diff stats
.env.default
... | ... | @@ -15,6 +15,8 @@ ERRBIT_PER_APP_EMAIL_AT_NOTICES=false |
15 | 15 | ERRBIT_NOTIFY_AT_NOTICES='[0]' |
16 | 16 | ERRBIT_PER_APP_NOTIFY_AT_NOTICES=false |
17 | 17 | MONGO_URL='mongodb://localhost' |
18 | +ERRBIT_LOG_LEVEL=info | |
19 | +ERRBIT_LOG_LOCATION=STDOUT | |
18 | 20 | GITHUB_URL='https://github.com' |
19 | 21 | GITHUB_AUTHENTICATION=true |
20 | 22 | GITHUB_ACCESS_SCOPE='[repo]' | ... | ... |
app/controllers/notices_controller.rb
... | ... | @@ -2,7 +2,8 @@ class NoticesController < ApplicationController |
2 | 2 | |
3 | 3 | class ParamsError < StandardError; end |
4 | 4 | |
5 | - skip_before_action :authenticate_user!, :only => :create | |
5 | + skip_before_action :authenticate_user!, only: :create | |
6 | + skip_before_filter :verify_authenticity_token, only: :create | |
6 | 7 | |
7 | 8 | rescue_from ParamsError, :with => :bad_params |
8 | 9 | ... | ... |
app/models/backtrace.rb
... | ... | @@ -15,11 +15,11 @@ class Backtrace |
15 | 15 | delegate :app, :to => :notice |
16 | 16 | |
17 | 17 | def self.find_or_create(attributes = {}) |
18 | - new(attributes).similar || create(attributes) | |
18 | + new(attributes).similar.find_and_modify({ '$setOnInsert' => attributes }) | |
19 | 19 | end |
20 | 20 | |
21 | 21 | def similar |
22 | - Backtrace.where(:fingerprint => fingerprint).first | |
22 | + Backtrace.where(:fingerprint => fingerprint) | |
23 | 23 | end |
24 | 24 | |
25 | 25 | def raw=(raw) |
... | ... | @@ -32,5 +32,4 @@ class Backtrace |
32 | 32 | def generate_fingerprint |
33 | 33 | self.fingerprint = Digest::SHA1.hexdigest(lines.map(&:to_s).join) |
34 | 34 | end |
35 | - | |
36 | 35 | end | ... | ... |
config/application.rb
... | ... | @@ -19,9 +19,6 @@ module Errbit |
19 | 19 | config.autoload_paths += [Rails.root.join('lib')] |
20 | 20 | |
21 | 21 | config.before_initialize do |
22 | - # Load up Errbit::Config with values from the environment | |
23 | - require Rails.root.join('config/load') | |
24 | - | |
25 | 22 | config.secret_key_base = Errbit::Config.secret_key_base |
26 | 23 | config.serve_static_assets = Errbit::Config.serve_static_assets |
27 | 24 | end | ... | ... |
config/environment.rb
1 | 1 | # Load the Rails application. |
2 | 2 | require File.expand_path('../application', __FILE__) |
3 | 3 | |
4 | +# Load up Errbit::Config with values from the environment | |
5 | +require Rails.root.join('config/load') | |
6 | + | |
7 | +if Errbit::Config.log_location == 'STDOUT' | |
8 | + Rails.logger = ActiveSupport::Logger.new STDOUT | |
9 | +else | |
10 | + Rails.logger = ActiveSupport::Logger.new Errbit::Config.log_location | |
11 | +end | |
12 | + | |
13 | +Rails.logger.level = Errbit::Config.log_level.to_sym | |
14 | + | |
4 | 15 | # Initialize the Rails application. |
5 | 16 | Rails.application.initialize! | ... | ... |
config/initializers/mongo.rb
config/load.rb
1 | 1 | # load default ENV values (without overwriting any existing value) |
2 | 2 | Dotenv.load('.env.default') |
3 | 3 | |
4 | +require_relative '../lib/configurator' | |
5 | + | |
4 | 6 | # map config keys to environment variables |
5 | 7 | # |
6 | 8 | # We use the first non-nil environment variable in the list. If the last array |
... | ... | @@ -19,6 +21,8 @@ Errbit::Config = Configurator.run({ |
19 | 21 | per_app_email_at_notices: ['ERRBIT_PER_APP_EMAIL_AT_NOTICES'], |
20 | 22 | notify_at_notices: ['ERRBIT_NOTIFY_AT_NOTICES'], |
21 | 23 | per_app_notify_at_notices: ['ERRBIT_PER_APP_NOTIFY_AT_NOTICES'], |
24 | + log_location: ['ERRBIT_LOG_LOCATION'], | |
25 | + log_level: ['ERRBIT_LOG_LEVEL'], | |
22 | 26 | |
23 | 27 | serve_static_assets: ['SERVE_STATIC_ASSETS'], |
24 | 28 | secret_key_base: ['SECRET_KEY_BASE'], | ... | ... |
config/mongo.rb