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

Commit

Permalink
Add better debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Sep 6, 2016
1 parent 95f397c commit e1ef6e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/timber/log_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class InvalidMessageError < ArgumentError; end
attr_reader :context_snapshot, :dt, :line_indexes, :message

def initialize(message)
puts message.inspect
puts "\n\n#{message}\n#{caller[0..5].join("\n")}"
@dt = Time.now.utc # Capture the time as soon as possible
message = message.to_s # TODO: handle converting objects to json or kv?
message = message.to_s
if message.bytesize > APISettings::MESSAGE_BYTE_SIZE_MAX
raise InvalidMessageError.new("the log message must not exceed " +
"#{APISettings::MESSAGE_BYTE_SIZE_MAX} bytes")
Config.logger.warn("Log line message is too long, truncating")
message = message.byteslice(0, APISettings::MESSAGE_BYTE_SIZE_MAX)
end
@message = message
CurrentLineIndexes.log_line_added(self) # Bump the indexes
Expand Down
4 changes: 2 additions & 2 deletions spec/timber/log_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
context "exceeds bytesize limit" do
let(:limit) { Timber::APISettings::MESSAGE_BYTE_SIZE_MAX }
let(:message) { (1..(limit + 1)).collect { "A" }.join }
subject { lambda { log_line } }
it { should raise_error(Timber::LogLine::InvalidMessageError, "the log message must not exceed #{limit} bytes") }
its(:message) { should_not eq(message) }
its(:message) { should eq(message.byteslice(0, Timber::APISettings::MESSAGE_BYTE_SIZE_MAX)) }
end

it "notifies CurrentLineIndexes" do
Expand Down

0 comments on commit e1ef6e1

Please sign in to comment.