diff --git a/EPLogger.podspec b/EPLogger.podspec index 2ad6962..b6a6af2 100755 --- a/EPLogger.podspec +++ b/EPLogger.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'EPLogger' - s.version = '1.1.3' + s.version = '1.2.3' s.summary = 'Just simple Logger' # This description is used to generate tags and improve search results. diff --git a/EPLogger/Classes/EPLogger.swift b/EPLogger/Classes/EPLogger.swift index 7369321..27c10e9 100755 --- a/EPLogger/Classes/EPLogger.swift +++ b/EPLogger/Classes/EPLogger.swift @@ -12,6 +12,18 @@ fileprivate extension DispatchQueue { return String(validatingUTF8: __dispatch_queue_get_label(nil)) } } +extension Log { + public enum PrinterType { + /// use `print()` + case `default` + + /// use `debugPrint()` + case debug + + /// use `dump()` + case dump + } +} extension Log { public enum Level: String { @@ -80,7 +92,7 @@ public struct Log { return String(format: "%p", Thread.current) } } - + /// Custom Level Header /// /// ex) @@ -199,8 +211,7 @@ public struct Log { fileName: String, line: UInt, funcName: String, - useDebugPrint: Bool, - useDump: Bool, + printerType: Log.PrinterType, output: Any ) { #if DEBUG @@ -214,7 +225,7 @@ public struct Log { internalQueue.sync { guard let items = output as? [Any] else { - logPrinter(logString, useDebugPrint, useDump, value: output) + logPrinter(logString, printerType, value: output) return } @@ -222,47 +233,52 @@ public struct Log { case 0: Swift.print(logString) case 1: - logPrinter(logString, useDebugPrint, useDump, value: items[0]) + logPrinter(logString, printerType, value: items[0]) default: - multipleItemLogPrinter(logString, useDebugPrint, useDump, items: items) + multipleItemLogPrinter(logString, printerType, items: items) } } #endif } - private static func logPrinter(_ logString: String, _ useDebugPrint: Bool, _ useDump: Bool, value: Any) { - if useDump { + private static func logPrinter(_ logString: String, _ printType: Log.PrinterType, value: Any) { + switch printType { + case .debug: + Swift.print("\(logString)\(separator)", terminator: "") + Swift.debugPrint(value) + + case .dump: Swift.print("\(logString)\(separator)") Swift.dump(value, name: name(value), indent: 2) - } else { + + case .default: Swift.print("\(logString)\(separator)", terminator: "") - if useDebugPrint { - Swift.debugPrint(value) - } else { - Swift.print(value) - } + Swift.print(value) } } private static func multipleItemLogPrinter( _ logString: String, - _ useDebugPrint: Bool, - _ useDump: Bool, + _ printType: Log.PrinterType, items: [Any] ) { - if useDump { + switch printType { + case .debug: + Swift.print("\(logString) ▽") + for item in items { + Swift.debugPrint(item) + } + + case .dump: Swift.print("\(logString) ▽") for item in items { Swift.dump(item, name: name(item), indent: 2) } - } else { + + case .default: Swift.print("\(logString) ▽") for item in items { - if useDebugPrint { - Swift.debugPrint(item) - } else { - Swift.print(item) - } + Swift.print(item) } } } @@ -275,8 +291,7 @@ public struct Log { fileName: String = #file, line: UInt = #line, funcName: String = #function, - useDebugPrint: Bool = false, - useDump: Bool = false, + printBy printerType: Log.PrinterType = .default, _ output: Any... ) { logger( @@ -284,8 +299,7 @@ public struct Log { fileName: fileName, line: line, funcName: funcName, - useDebugPrint: useDebugPrint, - useDump: useDump, + printerType: printerType, output: output ) } @@ -294,8 +308,7 @@ public struct Log { fileName: String = #file, line: UInt = #line, funcName: String = #function, - useDebugPrint: Bool = false, - useDump: Bool = false, + printBy printerType: Log.PrinterType = .default, _ output: Any... ) { logger( @@ -303,8 +316,7 @@ public struct Log { fileName: fileName, line: line, funcName: funcName, - useDebugPrint: useDebugPrint, - useDump: useDump, + printerType: printerType, output: output ) } @@ -313,8 +325,7 @@ public struct Log { fileName: String = #file, line: UInt = #line, funcName: String = #function, - useDebugPrint: Bool = false, - useDump: Bool = false, + printBy printerType: Log.PrinterType = .default, _ output: Any... ) { logger( @@ -322,8 +333,7 @@ public struct Log { fileName: fileName, line: line, funcName: funcName, - useDebugPrint: useDebugPrint, - useDump: useDump, + printerType: printerType, output: output ) } @@ -332,8 +342,7 @@ public struct Log { fileName: String = #file, line: UInt = #line, funcName: String = #function, - useDebugPrint: Bool = false, - useDump: Bool = false, + printBy printerType: Log.PrinterType = .default, _ output: Any... ) { logger( @@ -341,8 +350,7 @@ public struct Log { fileName: fileName, line: line, funcName: funcName, - useDebugPrint: useDebugPrint, - useDump: useDump, + printerType: printerType, output: output ) } @@ -351,8 +359,7 @@ public struct Log { fileName: String = #file, line: UInt = #line, funcName: String = #function, - useDebugPrint: Bool = false, - useDump: Bool = false, + printBy printerType: Log.PrinterType = .default, _ output: Any... ) { logger( @@ -360,8 +367,7 @@ public struct Log { fileName: fileName, line: line, funcName: funcName, - useDebugPrint: useDebugPrint, - useDump: useDump, + printerType: printerType, output: output ) } diff --git a/Example/EPLogger.xcodeproj/project.pbxproj b/Example/EPLogger.xcodeproj/project.pbxproj index 4e258fb..1708588 100755 --- a/Example/EPLogger.xcodeproj/project.pbxproj +++ b/Example/EPLogger.xcodeproj/project.pbxproj @@ -490,7 +490,7 @@ DEVELOPMENT_TEAM = M77W68G9P5; INFOPLIST_FILE = EPLogger/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.1.3; + MARKETING_VERSION = 1.2.3; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -507,7 +507,7 @@ DEVELOPMENT_TEAM = M77W68G9P5; INFOPLIST_FILE = EPLogger/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.1.3; + MARKETING_VERSION = 1.2.3; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Example/EPLogger/ViewController.swift b/Example/EPLogger/ViewController.swift index 58731c2..b3b03eb 100755 --- a/Example/EPLogger/ViewController.swift +++ b/Example/EPLogger/ViewController.swift @@ -32,27 +32,27 @@ final class ViewController: UIViewController { let text = "Sample String!" Log.verbose(text) - Log.verbose(useDebugPrint: true, text) - Log.verbose(useDump: true, text) + Log.verbose(printBy: .debug, text) + Log.verbose(printBy: .dump, text) print("") let sample = SampleStruct() Log.debug(sample) - Log.debug(useDebugPrint: true, sample) - Log.debug(useDump: true, sample) + Log.debug(printBy: .debug, sample) + Log.debug(printBy: .dump, sample) print("") Log.verbose(StringEnum.normal) - Log.verbose(useDebugPrint: true, StringEnum.vip) - Log.verbose(useDump: true, StringEnum.vvip) + Log.verbose(printBy: .debug, StringEnum.vip) + Log.verbose(printBy: .dump, StringEnum.vvip) print("") Log.debug(IntEnum.one) - Log.debug(useDebugPrint: true, IntEnum.one) - Log.debug(useDump: true, IntEnum.two) + Log.debug(printBy: .debug, IntEnum.one) + Log.debug(printBy: .dump, IntEnum.two) } private func logItems() { @@ -61,8 +61,8 @@ final class ViewController: UIViewController { let text = "Sample String2!" let sample = SampleStruct() Log.verbose(text, sample, StringEnum.vvip, IntEnum.two) - Log.verbose(useDebugPrint: true, text, sample, StringEnum.vvip, IntEnum.two) - Log.verbose(useDump: true, text, sample, StringEnum.vvip, IntEnum.two) + Log.verbose(printBy: .debug, text, sample, StringEnum.vvip, IntEnum.two) + Log.verbose(printBy: .dump, text, sample, StringEnum.vvip, IntEnum.two) } private func changeFormat() { diff --git a/Example/Podfile.lock b/Example/Podfile.lock index bd14fe9..0005438 100755 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - EPLogger (1.1.3) + - EPLogger (1.2.3) DEPENDENCIES: - EPLogger (from `../`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - EPLogger: 930e32636081f0e1804a02997ebb89761d1bcfbc + EPLogger: bb3e393551103894bd1d96bad4556cb54519a32d PODFILE CHECKSUM: a8631a7901040d7ddac01ffc59b141f98c4bef73 diff --git a/Example/Pods/Local Podspecs/EPLogger.podspec.json b/Example/Pods/Local Podspecs/EPLogger.podspec.json index e55ae1b..56a3668 100755 --- a/Example/Pods/Local Podspecs/EPLogger.podspec.json +++ b/Example/Pods/Local Podspecs/EPLogger.podspec.json @@ -1,6 +1,6 @@ { "name": "EPLogger", - "version": "1.1.3", + "version": "1.2.3", "summary": "Just simple Logger", "description": "Just simple Logger\n\n```swift\n\n // Log level. default is verbose\n Log.config(level: .debug)\n\n Log.verbose(\"verbose\")\n Log.debug(\"debug\")\n Log.warning(\"warning\")\n Log.error(\"error\")\n```", "homepage": "https://github.com/ElonPark/EPLogger", @@ -17,7 +17,7 @@ }, "source": { "git": "https://github.com/ElonPark/EPLogger.git", - "tag": "1.1.3" + "tag": "1.2.3" }, "platforms": { "ios": "8.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index bd14fe9..0005438 100755 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - EPLogger (1.1.3) + - EPLogger (1.2.3) DEPENDENCIES: - EPLogger (from `../`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - EPLogger: 930e32636081f0e1804a02997ebb89761d1bcfbc + EPLogger: bb3e393551103894bd1d96bad4556cb54519a32d PODFILE CHECKSUM: a8631a7901040d7ddac01ffc59b141f98c4bef73 diff --git a/Example/Pods/Target Support Files/EPLogger/EPLogger-Info.plist b/Example/Pods/Target Support Files/EPLogger/EPLogger-Info.plist index bfb8987..7950ae3 100755 --- a/Example/Pods/Target Support Files/EPLogger/EPLogger-Info.plist +++ b/Example/Pods/Target Support Files/EPLogger/EPLogger-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.3 + 1.2.3 CFBundleSignature ???? CFBundleVersion