Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Mar 17, 2017
1 parent 36e778b commit 1526d9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion config/initializers/timber.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
config.timber.log_device = Timber::LogDevices::HTTP.new("132_f25beed781edf9f0:6bfa5d7b70c9b81f2f2b2ab663f2d02ad5a00726bfe183dd3fada9aa9d7f86c5")

# More config options can be found at: https://timber.io/docs/ruby/configuration/
#
# Question? Need help?
Contact us: support@timber.io
# * Docs: https://timber.io/docs
# * Support: support@timber.io
4 changes: 3 additions & 1 deletion lib/timber/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ def run(api_key)
def create_initializer(log_device, app)
body = "config.timber.log_device = Timber::LogDevices::HTTP.new(\"#{app.api_key}\")\n\n" \
"# More config options can be found at: https://timber.io/docs/ruby/configuration/\n" \
"#\n" \
"# Question? Need help?\n" \
"Contact us: support@timber.io"
"# * Docs: https://timber.io/docs\n" \
"# * Support: support@timber.io" \

FileUtils.mkdir_p(File.join(Dir.pwd, "config", "initializers"))
File.write(File.join(Dir.pwd, "config/initializers/timber.rb"), body)
Expand Down
14 changes: 8 additions & 6 deletions lib/timber/frameworks/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ class Railtie < ::Rails::Railtie
initializer(:timber_logger, before: :initialize_logger) do
# The environment files have already been loaded. Timber configuration
# could have been set in there and it should be respected.
log_device = Config.instance.log_device
logger = ::ActiveSupport::TaggedLogging.new(Logger.new(log_device))
::Rails.logger = config.logger = logger
Rails.apply_logger
end

config.after_initialize do
# Check that the logger is set properly, if not, raise
# re-apply the timber logger to rails in case they changed it

Rails.apply_logger
Probes.insert!
Rails.insert_middlewares(config.app_middleware)
end
end

def self.apply_logger
log_device = Config.instance.log_device
logger = ::ActiveSupport::TaggedLogging.new(Logger.new(log_device))
::Rails.logger = config.logger = logger
end

def self.insert_middlewares(middleware)
var_name = :"@_timber_middlewares_inserted"
return true if middleware.instance_variable_defined?(var_name) && middleware.instance_variable_get(var_name) == true
Expand Down
2 changes: 1 addition & 1 deletion lib/timber/log_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Timber
# `Logger` and the log device that you set it up with.
class LogEntry #:nodoc:
DT_PRECISION = 6.freeze
SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.18/schema.json".freeze
SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.19/schema.json".freeze

attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time, :time_ms

Expand Down

0 comments on commit 1526d9e

Please sign in to comment.