Skip to content

Commit

Permalink
Use data from Dexter (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcsmith committed Jun 16, 2020
1 parent 5d79073 commit b262004
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion spec/lucky/pretty_log_formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ end

private def format(io, data : NamedTuple?, message : String = "", severity = Log::Severity::Info, exception : Exception? = nil)
Log.with_context do
Log.context.set(local: data) if data

entry = Log::Entry.new \
source: "lucky-test",
message: message,
severity: severity,
data: Log::Metadata.build(data || Log::Metadata.empty),
data: Log::Metadata.build(Log::Metadata.empty),
exception: exception

Lucky::PrettyLogFormatter.new(
Expand Down
4 changes: 3 additions & 1 deletion src/lucky/pretty_log_formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ struct Lucky::PrettyLogFormatter < Dexter::BaseFormatter

def local_context
res = Hash(String, ::Log::Metadata::Value).new
entry.data.each do |key, value|

entry.context[:local]?.try &.as_h.each do |key, value|
res[key.to_s] = value
end

res
end

Expand Down

0 comments on commit b262004

Please sign in to comment.