feat: add builtin log function

This commit is contained in:
xaseiresh 2023-04-12 10:04:05 +02:00
parent f908eb1e22
commit e107825c59

View file

@ -61,6 +61,8 @@ module Comfpile
@included_artefacts = []
@referenced_artefacts = []
@log_current_level = :debug
@log_current_line = "Not started..."
@steps = []
@step_additions = nil
@ -86,6 +88,30 @@ module Comfpile
@parameters[key] = value
end
#
# Log an event for this artefact.
# Saves the given argument as log line,
# optionally prints it to a logger. Use this to
# save state progress messages as well as
# error messages.
#
# @param [String] text Text message to log
# @param [Symbol] state Level to log at. Known levels
# are:
# - :debug
# - :info
# - :warning
# - :error
#
def log(text, level = :debug)
@log_current_line = text
@log_current_level = level
puts "> #{@state} #{@target}: #{text}"
nil
end
private def add_step_data(data)
@step_additions ||= []