From 5be65820232b32bf74754373f4190a3f2e3236dc Mon Sep 17 00:00:00 2001 From: Matthew Colegate Date: Mon, 22 May 2017 13:24:48 +0100 Subject: [PATCH 1/4] Copy env message locally; fix minor compilation warnings --- Sources/SwiftBAMDC/SwiftDataCollector.swift | 4 ---- Sources/SwiftMetrics/SwiftMetrics.swift | 2 +- Sources/SwiftMetrics/SwiftMonitor.swift | 5 +++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Sources/SwiftBAMDC/SwiftDataCollector.swift b/Sources/SwiftBAMDC/SwiftDataCollector.swift index 2b8263d..4aa562e 100755 --- a/Sources/SwiftBAMDC/SwiftDataCollector.swift +++ b/Sources/SwiftBAMDC/SwiftDataCollector.swift @@ -38,10 +38,6 @@ public class SwiftDataCollectorInit { var sm:SwiftMetrics - var logLevel : LoggerMessageType = .info - - logLevel = self.bamConfig.logLevel - sm = swiftMetricsInstance self.monitor = sm.monitor() diff --git a/Sources/SwiftMetrics/SwiftMetrics.swift b/Sources/SwiftMetrics/SwiftMetrics.swift index 68259fc..5ac27f4 100644 --- a/Sources/SwiftMetrics/SwiftMetrics.swift +++ b/Sources/SwiftMetrics/SwiftMetrics.swift @@ -69,7 +69,7 @@ private func receiveAgentCoreData(cSourceId: UnsafePointer, cSize: CUnsig let opaquePointer = OpaquePointer(data) let cstrPointer = UnsafePointer(opaquePointer) - let message = String(cString:cstrPointer) ?? "" + let message = String(cString:cstrPointer) if swiftMon != nil { swiftMon!.raiseCoreEvent(topic: source, message: message) } diff --git a/Sources/SwiftMetrics/SwiftMonitor.swift b/Sources/SwiftMetrics/SwiftMonitor.swift index 4b040df..1565674 100644 --- a/Sources/SwiftMetrics/SwiftMonitor.swift +++ b/Sources/SwiftMetrics/SwiftMonitor.swift @@ -168,7 +168,7 @@ public class SwiftMonitor { } } - private func formatOSEnv(message: String) { + private func formatOSEnv(incMessage: String) { if(running) { swiftMetrics.loaderApi.logMessage(debug, "formatOSEnv(): Raising OS Environment event") /* environment_os: #EnvironmentSource @@ -183,6 +183,7 @@ public class SwiftMonitor { number.of.processors=2 command.line=/home/exampleuser/SwiftMetrics/sample/.build/debug/test */ + let message = incMessage let values = message.components(separatedBy: "\n") var env: [ String : String ] = [:] for value in values { @@ -294,7 +295,7 @@ public class SwiftMonitor { case "common_memory", "memory": formatMemory(messages: message) case "common_env": - formatOSEnv(message: message) + formatOSEnv(incMessage: message) default: ///ignore other messages swiftMetrics.loaderApi.logMessage(debug, "raiseCoreEvent(): Topic not recognised - ignoring event") From 3f0d426e57b7f88db8c7d0511604284511344049 Mon Sep 17 00:00:00 2001 From: Matthew Colegate Date: Mon, 22 May 2017 15:00:35 +0100 Subject: [PATCH 2/4] Undo message copy; output message --- Sources/SwiftMetrics/SwiftMonitor.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftMetrics/SwiftMonitor.swift b/Sources/SwiftMetrics/SwiftMonitor.swift index 1565674..8d62c08 100644 --- a/Sources/SwiftMetrics/SwiftMonitor.swift +++ b/Sources/SwiftMetrics/SwiftMonitor.swift @@ -168,7 +168,7 @@ public class SwiftMonitor { } } - private func formatOSEnv(incMessage: String) { + private func formatOSEnv(message: String) { if(running) { swiftMetrics.loaderApi.logMessage(debug, "formatOSEnv(): Raising OS Environment event") /* environment_os: #EnvironmentSource @@ -183,7 +183,7 @@ public class SwiftMonitor { number.of.processors=2 command.line=/home/exampleuser/SwiftMetrics/sample/.build/debug/test */ - let message = incMessage + print("Incoming message: \(incMessage)") let values = message.components(separatedBy: "\n") var env: [ String : String ] = [:] for value in values { @@ -295,7 +295,7 @@ public class SwiftMonitor { case "common_memory", "memory": formatMemory(messages: message) case "common_env": - formatOSEnv(incMessage: message) + formatOSEnv(message: message) default: ///ignore other messages swiftMetrics.loaderApi.logMessage(debug, "raiseCoreEvent(): Topic not recognised - ignoring event") From 32b111b041ec715940bf6f7b058aff0db8cd8629 Mon Sep 17 00:00:00 2001 From: Matthew Colegate Date: Mon, 22 May 2017 15:06:03 +0100 Subject: [PATCH 3/4] Use the right variable name --- Sources/SwiftMetrics/SwiftMonitor.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftMetrics/SwiftMonitor.swift b/Sources/SwiftMetrics/SwiftMonitor.swift index 8d62c08..7d8d76a 100644 --- a/Sources/SwiftMetrics/SwiftMonitor.swift +++ b/Sources/SwiftMetrics/SwiftMonitor.swift @@ -183,7 +183,7 @@ public class SwiftMonitor { number.of.processors=2 command.line=/home/exampleuser/SwiftMetrics/sample/.build/debug/test */ - print("Incoming message: \(incMessage)") + print("Incoming message: \(message)") let values = message.components(separatedBy: "\n") var env: [ String : String ] = [:] for value in values { From d822b9017c093200c6a7a9d6c7b9ff2e06df9400 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Tue, 20 Jun 2017 06:34:52 +0100 Subject: [PATCH 4/4] Remove debug print statement --- Sources/SwiftMetrics/SwiftMonitor.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/SwiftMetrics/SwiftMonitor.swift b/Sources/SwiftMetrics/SwiftMonitor.swift index 7d8d76a..4b040df 100644 --- a/Sources/SwiftMetrics/SwiftMonitor.swift +++ b/Sources/SwiftMetrics/SwiftMonitor.swift @@ -183,7 +183,6 @@ public class SwiftMonitor { number.of.processors=2 command.line=/home/exampleuser/SwiftMetrics/sample/.build/debug/test */ - print("Incoming message: \(message)") let values = message.components(separatedBy: "\n") var env: [ String : String ] = [:] for value in values {