Skip to content

Commit

Permalink
Merge pull request #522 from Fryguy/add_service_to_loggers
Browse files Browse the repository at this point in the history
Add progname processing to MiqLoggerProcessor
  • Loading branch information
bdunne authored Jun 21, 2021
2 parents 33de787 + e868941 commit 11c6c05
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 21 deletions.
17 changes: 12 additions & 5 deletions lib/gems/pending/util/miq_logger_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def parts
alias_method :to_a, :parts
alias_method :split, :parts

PARTS = %w(time pid tid level q_task_id fq_method message).freeze
PARTS = %w(time pid tid level progname q_task_id fq_method message).freeze
PARTS.each_with_index do |m, i|
define_method(m) { parts[i] }
end
Expand All @@ -148,9 +148,16 @@ def self.split_raw_line(line)
pidtid = line[39...bracket_index]
pid, tid = pidtid.split(':')

level = line[bracket_index + 2, 5].strip
level_index = bracket_index + 2
level = line[level_index, 5].strip

message = line[bracket_index + 13..-1]
progname_index = level_index + 9 # 5 for the level + 4 for the " -- "
message_index = line.index(": ", progname_index) + 2 # Find up to the ": " separator for the message

progname = line[progname_index...message_index].strip[0..-2]
progname = nil if progname.empty?

message = line[message_index..-1]
if message[0, 9] == "Q-task_id"
q_bracket_index = message.index(']', 11)
q_task_id = message[11...q_bracket_index]
Expand All @@ -161,8 +168,8 @@ def self.split_raw_line(line)
fq_method = message[/^MIQ\(([\d\w\:\.\#\_\-]*)\)/, 1] if message && message.start_with?("MIQ(")
message.chomp!

return time, pid, tid, level, q_task_id, fq_method, message
return time, pid, tid, level, progname, q_task_id, fq_method, message
rescue
return nil, nil, nil, nil, nil, line
return nil, nil, nil, nil, nil, nil, line
end
end
20 changes: 11 additions & 9 deletions spec/util/data/miq_logger_processor.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[----] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
[----] I, [2011-02-07T17:31:05.282104 #4909:03941abd4fe] INFO -- : MIQ(EmsRefreshWorker) ID [108482], PID [14909], GUID [0461c4a4-32e0-11e0-89ad-0050569a00bb], Zone [WB], Active Roles
[----] I, [2011-02-07T17:31:05.282996 #14909:15aee2c37f0c] INFO -- : :cpu_usage_threshold: 100
this
is a
multiline
[----] I, [2011-02-07T07:49:16.719656 #23130:15c945a976fc] INFO -- : Q-task_id([1753657a-3288-11e0-bd88-0050569a00ba]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...
[----] I, [2011-02-07T10:41:37.668866 #29614:15a82de14700] INFO -- : Q-task_id([job_dispatcher]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...
[1234] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
[----] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- evm: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
[----] I, [2011-02-07T17:31:59.744697 #14909:15aee2c37f0c] INFO -- development: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
[----] I, [2011-02-07T17:32:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
[----] I, [2011-02-07T17:31:05.282104 #4909:03941abd4fe] INFO -- evm: MIQ(EmsRefreshWorker) ID [108482], PID [14909], GUID [0461c4a4-32e0-11e0-89ad-0050569a00bb], Zone [WB], Active Roles
[----] I, [2011-02-07T17:31:05.282996 #14909:15aee2c37f0c] INFO -- evm: :cpu_usage_threshold: 100
this
is a
multiline
[----] I, [2011-02-07T07:49:16.719656 #23130:15c945a976fc] INFO -- evm: Q-task_id([1753657a-3288-11e0-bd88-0050569a00ba]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...
[----] I, [2011-02-07T10:41:37.668866 #29614:15a82de14700] INFO -- evm: Q-task_id([job_dispatcher]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...
[1234] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- evm: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []
42 changes: 35 additions & 7 deletions spec/util/miq_logger_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,89 @@

EXPECTED_LINE_PARTS = [
[
"[----] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\r\n",
"[----] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- evm: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\n",
"2011-02-07T17:30:59.744697",
"14909",
"15aee2c37f0c",
"INFO",
"evm",
nil,
"SQLServer.apply_connection_config",
"MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []",
],
[
"[----] I, [2011-02-07T17:31:05.282104 #4909:03941abd4fe] INFO -- : MIQ(EmsRefreshWorker) ID [108482], PID [14909], GUID [0461c4a4-32e0-11e0-89ad-0050569a00bb], Zone [WB], Active Roles\r\n",
"[----] I, [2011-02-07T17:31:59.744697 #14909:15aee2c37f0c] INFO -- development: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\n",
"2011-02-07T17:31:59.744697",
"14909",
"15aee2c37f0c",
"INFO",
"development",
nil,
"SQLServer.apply_connection_config",
"MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []",
],
[
"[----] I, [2011-02-07T17:32:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\n",
"2011-02-07T17:32:59.744697",
"14909",
"15aee2c37f0c",
"INFO",
nil,
nil,
"SQLServer.apply_connection_config",
"MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []",
],
[
"[----] I, [2011-02-07T17:31:05.282104 #4909:03941abd4fe] INFO -- evm: MIQ(EmsRefreshWorker) ID [108482], PID [14909], GUID [0461c4a4-32e0-11e0-89ad-0050569a00bb], Zone [WB], Active Roles\n",
"2011-02-07T17:31:05.282104",
"4909",
"03941abd4fe",
"INFO",
"evm",
nil,
"EmsRefreshWorker",
"MIQ(EmsRefreshWorker) ID [108482], PID [14909], GUID [0461c4a4-32e0-11e0-89ad-0050569a00bb], Zone [WB], Active Roles",
],
[
"[----] I, [2011-02-07T17:31:05.282996 #14909:15aee2c37f0c] INFO -- : :cpu_usage_threshold: 100\r\nthis\r\nis a\r\nmultiline\r\n",
"[----] I, [2011-02-07T17:31:05.282996 #14909:15aee2c37f0c] INFO -- evm: :cpu_usage_threshold: 100\nthis\nis a\nmultiline\n",
"2011-02-07T17:31:05.282996",
"14909",
"15aee2c37f0c",
"INFO",
"evm",
nil,
nil,
" :cpu_usage_threshold: 100\r\nthis\r\nis a\r\nmultiline",
" :cpu_usage_threshold: 100\nthis\nis a\nmultiline",
],
[
"[----] I, [2011-02-07T07:49:16.719656 #23130:15c945a976fc] INFO -- : Q-task_id([1753657a-3288-11e0-bd88-0050569a00ba]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...\r\n",
"[----] I, [2011-02-07T07:49:16.719656 #23130:15c945a976fc] INFO -- evm: Q-task_id([1753657a-3288-11e0-bd88-0050569a00ba]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...\n",
"2011-02-07T07:49:16.719656",
"23130",
"15c945a976fc",
"INFO",
"evm",
"1753657a-3288-11e0-bd88-0050569a00ba",
"MiqQueue.get",
"MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...",
],
[
"[----] I, [2011-02-07T10:41:37.668866 #29614:15a82de14700] INFO -- : Q-task_id([job_dispatcher]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...\r\n",
"[----] I, [2011-02-07T10:41:37.668866 #29614:15a82de14700] INFO -- evm: Q-task_id([job_dispatcher]) MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...\n",
"2011-02-07T10:41:37.668866",
"29614",
"15a82de14700",
"INFO",
"evm",
"job_dispatcher",
"MiqQueue.get",
"MIQ(MiqQueue.get) Message id: [18261690] stale, retrying...",
],
[
"[1234] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- : MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\r\n",
"[1234] I, [2011-02-07T17:30:59.744697 #14909:15aee2c37f0c] INFO -- evm: MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []\n",
"2011-02-07T17:30:59.744697",
"14909",
"15aee2c37f0c",
"INFO",
"evm",
nil,
"SQLServer.apply_connection_config",
"MIQ(SQLServer.apply_connection_config) trans_isolation_level: [], lock_timeout: []",
Expand Down

0 comments on commit 11c6c05

Please sign in to comment.