This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow recursion when writing log lines
- Loading branch information
1 parent
ea91e19
commit e97eae1
Showing
9 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
module Timber | ||
class LogDevice | ||
end | ||
NEWLINE = "\n".freeze | ||
SPLIT_LINES = true | ||
|
||
def write(message) | ||
return false if ignoring? | ||
ignore do | ||
messages(message).each do |message_part| | ||
log_line = LogLine.new(message_part) | ||
write_log_line(log_line) | ||
end | ||
end | ||
true | ||
rescue Exception => e | ||
Config.logger.exception(e) | ||
raise e | ||
end | ||
|
||
private | ||
def ignore(&block) | ||
@ignoring = true | ||
yield | ||
ensure | ||
@ignoring = false | ||
end | ||
|
||
def ignoring? | ||
@ignoring == true | ||
end | ||
|
||
def messages(message) | ||
message.chomp.split(NEWLINE) | ||
end | ||
|
||
def write_formatted(formatted_message) | ||
raise NotImplementedError.new | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters