diff --git a/lib/gems/pending/util/miq_logger_processor.rb b/lib/gems/pending/util/miq_logger_processor.rb index 8f58a51b2..23f95d9c5 100644 --- a/lib/gems/pending/util/miq_logger_processor.rb +++ b/lib/gems/pending/util/miq_logger_processor.rb @@ -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 @@ -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] @@ -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 diff --git a/spec/util/data/miq_logger_processor.log b/spec/util/data/miq_logger_processor.log index b5e17ef96..1dac765fb 100644 --- a/spec/util/data/miq_logger_processor.log +++ b/spec/util/data/miq_logger_processor.log @@ -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: [] diff --git a/spec/util/miq_logger_processor_spec.rb b/spec/util/miq_logger_processor_spec.rb index 8a6d2c321..d05f77726 100644 --- a/spec/util/miq_logger_processor_spec.rb +++ b/spec/util/miq_logger_processor_spec.rb @@ -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: []",