Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions QuantiLogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
9C6F8ED023A0EE240098FA4C /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C6F8ECF23A0EE240098FA4C /* RxSwift.framework */; platformFilter = ios; };
9C6F8ED523A0F0210098FA4C /* RxTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C6F8ED123A0EE2B0098FA4C /* RxTest.framework */; };
9C6F8ED723A0F02B0098FA4C /* RxRelay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C6F8ECD23A0EE1E0098FA4C /* RxRelay.framework */; };
9C74063226284F6C005B2E69 /* UIDevice+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C74063126284F6C005B2E69 /* UIDevice+.swift */; };
9C74064326285BC0005B2E69 /* UIDevice+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C74063126284F6C005B2E69 /* UIDevice+.swift */; };
9C740649262861F7005B2E69 /* UIDevice+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C74063126284F6C005B2E69 /* UIDevice+.swift */; };
D32E659320D15A5C00698F3E /* WebLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32E659220D15A5C00698F3E /* WebLogger.swift */; };
D32E659E20D15A7100698F3E /* JSONParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32E659420D15A6900698F3E /* JSONParser.swift */; };
D32E659F20D15A7100698F3E /* ApiFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32E659520D15A6A00698F3E /* ApiFactory.swift */; };
Expand Down Expand Up @@ -185,6 +188,7 @@
9C6F8ECF23A0EE240098FA4C /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/iOS/RxSwift.framework; sourceTree = SOURCE_ROOT; };
9C6F8ED123A0EE2B0098FA4C /* RxTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxTest.framework; path = Carthage/Build/iOS/RxTest.framework; sourceTree = SOURCE_ROOT; };
9C6F8ED323A0EE300098FA4C /* RxAtomic.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxAtomic.framework; path = Carthage/Build/iOS/RxAtomic.framework; sourceTree = SOURCE_ROOT; };
9C74063126284F6C005B2E69 /* UIDevice+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+.swift"; sourceTree = "<group>"; };
D32E659220D15A5C00698F3E /* WebLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebLogger.swift; sourceTree = "<group>"; };
D32E659420D15A6900698F3E /* JSONParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONParser.swift; sourceTree = "<group>"; };
D32E659520D15A6A00698F3E /* ApiFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiFactory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -315,6 +319,7 @@
FFF2456E24472F5B0028F625 /* Substring+.swift */,
5B164FBE23BDF65700A5F4E6 /* Date+.swift */,
5B164FC123BDF67800A5F4E6 /* Observable+.swift */,
9C74063126284F6C005B2E69 /* UIDevice+.swift */,
);
name = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -791,6 +796,7 @@
6C07CA8522CA6C740009203A /* LogFilesViaMailViewController.swift in Sources */,
D32E65A320D15A7100698F3E /* HttpMethod.swift in Sources */,
5BA3645D1DD0EDD10017F9EB /* LogFileRecord.swift in Sources */,
9C74063226284F6C005B2E69 /* UIDevice+.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -835,6 +841,7 @@
5BA6AB03226F42BA00FBB047 /* Data+Serialization.swift in Sources */,
5BF957471F5ED3A700F88F9B /* LogFileRecord.swift in Sources */,
FF2C2F0624640A7500399D9D /* Substring+.swift in Sources */,
9C74064326285BC0005B2E69 /* UIDevice+.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -863,6 +870,7 @@
6C5DF0B622C0E96600271501 /* ConsoleLogger.swift in Sources */,
FF2C2F0524640A4200399D9D /* Substring+.swift in Sources */,
6C5DF0B722C0E96600271501 /* ApiFactory.swift in Sources */,
9C740649262861F7005B2E69 /* UIDevice+.swift in Sources */,
6C5DF0B822C0E96600271501 /* SystemLogger.swift in Sources */,
6C5DF0B922C0E96600271501 /* ApiError.swift in Sources */,
6C5DF0BA22C0E96600271501 /* JSONParseable.swift in Sources */,
Expand Down
17 changes: 12 additions & 5 deletions QuantiLogger/common/MetaInformationLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
import UIKit
#endif

public enum MetaInformationType: String {
public enum MetaInformationType: String, CaseIterable {
case identifier = "CFBundleIdentifier"
case compiler = "DTCompiler"
case version = "CFBundleShortVersionString"
Expand All @@ -20,9 +20,8 @@ public enum MetaInformationType: String {
case currentOSVersion = "CurrentOSVersion"
case upTime = "UpTime"
case language = "Language"

static let allValues: [MetaInformationType] = [.identifier, .compiler, .version, .buildNumber,
.modelType, .currentOSVersion, .upTime, .language]
case cpuName = "CPUName"
case cpuSpeed = "CPUSpeed"
}

protocol MetaInformationLoggerDelegate: class {
Expand Down Expand Up @@ -100,11 +99,19 @@ class MetaInformationLogger {
data[MetaInformationType.language.rawValue] = _value
}

if dataToLog.contains(.cpuName) {
data[MetaInformationType.cpuName.rawValue] = UIDevice.current.cpuName
}

if dataToLog.contains(.cpuSpeed) {
data[MetaInformationType.cpuSpeed.rawValue] = UIDevice.current.cpuSpeed
}

return data
}

func log(_ dataToLog: [MetaInformationType], onLevel level: Level) {
let _dataToLog = dataToLog.count == 0 ? MetaInformationType.allValues : dataToLog
let _dataToLog = dataToLog.count == 0 ? MetaInformationType.allCases : dataToLog

delegate?.logMetaInformation("Meta information: \(values(for: _dataToLog))", onLevel: level)
}
Expand Down
79 changes: 79 additions & 0 deletions QuantiLogger/common/UIDevice+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// UIDevice+.swift
// QuantiLogger
//
// Created by George Ivannikov on 4/15/21.
// Copyright © 2021 quanti. All rights reserved.
//

import Foundation
import UIKit

extension UIDevice {
//Original Author: HAS
// https://stackoverflow.com/questions/33855998/how-to-get-hardware-details-in-swift
var cpuName: String {
Array(CPUinfo().keys)[0]
}

var cpuSpeed: String {
Array(CPUinfo().values)[0]
}

private func CPUinfo() -> [String: String] {
#if targetEnvironment(simulator)
let identifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"]!
#else

var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
#endif

switch identifier {
case "iPod5,1": return ["A5": "800 MHz"]
case "iPod7,1": return ["A8": "1.4 GHz"]
case "iPhone3,1", "iPhone3,2", "iPhone3,3": return ["A4": "800 MHz"]
case "iPhone4,1": return ["A5": "800 MHz"]
case "iPhone5,1", "iPhone5,2": return ["A6": "1.3 GHz"]
case "iPhone5,3", "iPhone5,4": return ["A6": "1.3 GHz"]
case "iPhone6,1", "iPhone6,2": return ["A7": "1.3 GHz"]
case "iPhone7,2": return ["A8": "1.4 GHz"]
case "iPhone7,1": return ["A8": "1.4 GHz"]
case "iPhone8,1": return ["A9": "1.85 GHz"]
case "iPhone8,2": return ["A9": "1.85 GHz"]
case "iPhone9,1", "iPhone9,3": return ["A10 Fusion": "2.34 GHz"]
case "iPhone9,2", "iPhone9,4": return ["A10 Fusion": "2.34 GHz"]
case "iPhone8,4": return ["A9": "1.85 GHz"]
case "iPhone10,1", "iPhone10,4": return ["A11 Bionic": "2.39 GHz"]
case "iPhone10,2", "iPhone10,5": return ["A11 Bionic": "2.39 GHz"]
case "iPhone10,3", "iPhone10,6": return ["A11 Bionic": "2.39 GHz"]
case "iPhone11,2", "iPhone11,4",
"iPhone11,6", "iPhone11,8": return ["A12": "2.5 GHz"]
case "iPhone12,1", "iPhone12,3", "iPhone12,5": return ["A13": "2650 GHz"]
case "iPhone12,8": return ["A13": "2.65 GHz"]
case "iPhone13,2", "iPhone13,1", "iPhone13,3": return ["A14": "2.99 GHz"]
case "iPhone13,4": return ["A14": "3.1 GHz"]
case "iPad2,1", "iPad2,2",
"iPad2,3", "iPad2,4": return ["A5": "1.0 GHz"]
case "iPad3,1", "iPad3,2", "iPad3,3": return ["A5X": "1.0 GHz"]
case "iPad3,4", "iPad3,5", "iPad3,6": return ["A6X": "1.4 GHz"]
case "iPad4,1", "iPad4,2", "iPad4,3": return ["A7": "1.4 GHz"]
case "iPad5,3", "iPad5,4": return ["A8X": "1.5 GHz"]
case "iPad6,11", "iPad6,12": return ["A9": "1.85 GHz"]
case "iPad2,5", "iPad2,6", "iPad2,7": return ["A5": "1.0 GHz"]
case "iPad4,4", "iPad4,5", "iPad4,6": return ["A7": "1.3 GHz"]
case "iPad4,7", "iPad4,8", "iPad4,9": return ["A7": "1.3 GHz"]
case "iPad5,1", "iPad5,2": return ["A8": "1.5 GHz"]
case "iPad6,3", "iPad6,4": return ["A9X": "2.16 GHz"]
case "iPad6,7", "iPad6,8": return ["A9X": "2.24 GHz"]
case "iPad7,1", "iPad7,2": return ["A10X Fusion": "2.34 GHz"]
case "iPad7,3", "iPad7,4": return ["A10X Fusion": "2.34 GHz"]
default: return ["N/A": "N/A"]
}
}
}