Module: Libis::Workflow::Base::Logging
- Included in:
- WorkItem
- Defined in:
- lib/libis/workflow/base/logging.rb
Instance Method Summary collapse
- #<=(message = {}) ⇒ Object
-
#add_log(message = {}) ⇒ Object
Helper function for the WorkItems to add a log entry to the log_history.
-
#log_message(severity, msg, *args) ⇒ Object
Add a structured message to the log history.
Instance Method Details
#<=(message = {}) ⇒ Object
47 48 49 |
# File 'lib/libis/workflow/base/logging.rb', line 47 def <=( = {}) self.add_log() end |
#add_log(message = {}) ⇒ Object
Helper function for the WorkItems to add a log entry to the log_history.
The supplied message structure is expected to contain the following fields:
-
:severity : ::Logger::Severity value
-
:id : optional message id
-
:text : message text
-
:task : list of tasks names (task hierarchy) that submits the message
40 41 42 43 44 45 |
# File 'lib/libis/workflow/base/logging.rb', line 40 def add_log( = {}) msg = () # noinspection RubyResolve add_log_entry(msg) self.save! end |
#log_message(severity, msg, *args) ⇒ Object
Add a structured message to the log history. The message text can be submitted as an integer or text. If an integer is submitted, it will be used to look up the text in the MessageRegistry. The message text will be passed to the % operator with the args parameter. If that failes (e.g. because the format string is not correct) the args value is appended to the message.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/libis/workflow/base/logging.rb', line 14 def (severity, msg, *args) # Prepare info from msg struct for use with string substitution , = if msg[:id] [msg[:id], MessageRegistry.instance.(msg[:id])] elsif msg[:text] [0, msg[:text]] else [0, ''] end task = msg[:task] || '' = ( % args rescue "#{} - #{args}") run_id = self.get_run.id rescue nil self.add_log severity: severity, id: .to_i, text: , task: task, run_id: run_id end |