Skip to content

Commit

Permalink
Merge pull request ManageIQ#213 from bdunne/prefix_task_id
Browse files Browse the repository at this point in the history
make prefixing the task id a method
  • Loading branch information
carbonin authored Jun 22, 2017
2 parents 23fd9dd + 36ec68f commit 838e3e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/gems/pending/util/vmdb-logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,21 @@ class Formatter < Logger::Formatter
FORMAT = "[----] %s, [%s#%d:%x] %5s -- %s: %s\n"

def call(severity, time, progname, msg)
msg = msg2str(msg)
msg = prefix_task_id(msg2str(msg))

FORMAT % [severity[0..0], format_datetime(time), $PROCESS_ID, Thread.current.object_id, severity, progname, msg]
end

private

def prefix_task_id(msg)
# Add task id to the message if a task is currently being worked on.
if $_miq_worker_current_msg && !$_miq_worker_current_msg.task_id.nil?
prefix = "Q-task_id([#{$_miq_worker_current_msg.task_id}])"
msg = "#{prefix} #{msg}" unless msg.include?(prefix)
end

FORMAT % [severity[0..0], format_datetime(time), $$, Thread.current.object_id, severity, progname, msg]
msg
end
end
end

0 comments on commit 838e3e0

Please sign in to comment.