From eac2679e086381f4a315d26620406a997422be2d Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 28 Dec 2020 19:58:27 +0100 Subject: [PATCH] feat: remove log to file from GPU module --- Modules/GPU/reader.swift | 8 ++++---- Stats/AppDelegate.swift | 2 +- StatsKit/helpers.swift | 12 ------------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Modules/GPU/reader.swift b/Modules/GPU/reader.swift index 3f798b27..18f4d3ef 100644 --- a/Modules/GPU/reader.swift +++ b/Modules/GPU/reader.swift @@ -34,13 +34,13 @@ internal class InfoReader: Reader { devices.forEach { (dict: NSDictionary) in guard let deviceID = dict["device-id"] as? Data, let vendorID = dict["vendor-id"] as? Data else { - print("device-id or vendor-id not found", to: &Log.log) + os_log(.error, log: log, "device-id or vendor-id not found") return } let pci = "0x" + Data([deviceID[1], deviceID[0], vendorID[1], vendorID[0]]).map { String(format: "%02hhX", $0) }.joined().lowercased() guard let modelData = dict["model"] as? Data, let modelName = String(data: modelData, encoding: .ascii) else { - print("GPU model not found", to: &Log.log) + os_log(.error, log: log, "GPU model not found") return } let model = modelName.replacingOccurrences(of: "\0", with: "") @@ -57,12 +57,12 @@ internal class InfoReader: Reader { accelerators.forEach { (accelerator: NSDictionary) in guard let IOClass = accelerator.object(forKey: "IOClass") as? String else { - print("IOClass not found", to: &Log.log) + os_log(.error, log: log, "IOClass not found") return } guard let stats = accelerator["PerformanceStatistics"] as? [String:Any] else { - print("PerformanceStatistics not found", to: &Log.log) + os_log(.error, log: log, "PerformanceStatistics not found") return } diff --git a/Stats/AppDelegate.swift b/Stats/AppDelegate.swift index bc3ccdcd..b3a050ea 100755 --- a/Stats/AppDelegate.swift +++ b/Stats/AppDelegate.swift @@ -42,7 +42,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele func applicationDidFinishLaunching(_ aNotification: Notification) { let startingPoint = Date() - print("------------", startingPoint, "------------", to: &Log.log) +// print("------------", startingPoint, "------------", to: &Log.log) self.parseArguments() diff --git a/StatsKit/helpers.swift b/StatsKit/helpers.swift index e0dcfb2d..409aa6c5 100644 --- a/StatsKit/helpers.swift +++ b/StatsKit/helpers.swift @@ -659,19 +659,7 @@ public class ColorView: NSView { public struct Log: TextOutputStream { public static var log: Log = Log() - private var debug: Bool = false - - private init() { - if CommandLine.arguments.contains("--debug") { - self.debug = true - } - } - public func write(_ string: String) { - if !debug { - return - } - let fm = FileManager.default let log = fm.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("log.txt") if let handle = try? FileHandle(forWritingTo: log) {