-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add log to diego stager error case (#4042)
- Without this log, the stack trace for the underlying error is lost, which makes debugging difficult - Add helper for testing log output. This makes it easier to validate the correct information is logged, without having to manually test.
- Loading branch information
Showing
4 changed files
with
90 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module LogHelpers | ||
class TailedLogs | ||
def initialize(io_log) | ||
@io_log = io_log | ||
end | ||
|
||
def read | ||
@io_log.string.split("\n").map { |l| Oj.load(l) } | ||
end | ||
end | ||
|
||
def tail_logs(&block) | ||
steno_config_backup = ::Steno.config | ||
|
||
begin | ||
io_log = ::StringIO.new | ||
io_sink = ::Steno::Sink::IO.new(io_log, codec: ::Steno::Codec::JsonRFC3339.new) | ||
::Steno.init(::Steno::Config.new( | ||
sinks: steno_config_backup.sinks + [io_sink], | ||
codec: steno_config_backup.codec, | ||
context: steno_config_backup.context, | ||
default_log_level: 'all' | ||
)) | ||
|
||
block.yield(TailedLogs.new(io_log)) | ||
ensure | ||
::Steno.init(steno_config_backup) | ||
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