feat: ✨ add builtin log function
This commit is contained in:
parent
f908eb1e22
commit
e107825c59
1 changed files with 26 additions and 0 deletions
|
@ -61,6 +61,8 @@ module Comfpile
|
||||||
@included_artefacts = []
|
@included_artefacts = []
|
||||||
@referenced_artefacts = []
|
@referenced_artefacts = []
|
||||||
|
|
||||||
|
@log_current_level = :debug
|
||||||
|
@log_current_line = "Not started..."
|
||||||
|
|
||||||
@steps = []
|
@steps = []
|
||||||
@step_additions = nil
|
@step_additions = nil
|
||||||
|
@ -86,6 +88,30 @@ module Comfpile
|
||||||
@parameters[key] = value
|
@parameters[key] = value
|
||||||
end
|
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)
|
private def add_step_data(data)
|
||||||
@step_additions ||= []
|
@step_additions ||= []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue