Skip to content

Commit

Permalink
Be able to set a logger per context
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Oct 16, 2024
1 parent 4a61d68 commit af60de2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/floe/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ def self.included(base)
end

def logger
Floe.logger
@logger || Floe.logger
end

def logger=(logger)
@logger = logger
end
end
end
4 changes: 3 additions & 1 deletion lib/floe/workflow/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Context

# @param context [Json|Hash] (default, create another with input and execution params)
# @param input [Hash] (default: {})
def initialize(context = nil, input: nil, credentials: {})
def initialize(context = nil, input: nil, credentials: {}, logger: nil)
context = JSON.parse(context) if context.kind_of?(String)
input = JSON.parse(input || "{}")

Expand All @@ -22,6 +22,8 @@ def initialize(context = nil, input: nil, credentials: {})
self["Task"] ||= {}

@credentials = credentials || {}

self.logger = logger if logger
rescue JSON::ParserError => err
raise Floe::InvalidExecutionInput, "Invalid State Machine Execution Input: #{err}: was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')"
end
Expand Down

0 comments on commit af60de2

Please sign in to comment.