5 // Created by Hori,Masaki on 2017/02/12.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
20 func higher(other: Level) -> Bool {
22 return self.rawValue >= other.rawValue
26 private struct Args: CustomStringConvertible, CustomDebugStringConvertible {
31 var description: String {
33 return args.map { "\($0)" }.joined(separator: separator)
36 var debugDescription: String {
39 .map { ($0 as? CustomDebugStringConvertible)?.debugDescription ?? "\($0)" }
40 .joined(separator: separator)
44 class func print(_ items: Any..., separator: String = " ", terminator: String = "\n", level: Level = .debug) {
46 excute(level: level) {
48 Swift.print(Args(args: items, separator: separator), separator: separator, terminator: terminator)
52 class func debugPrint(_ items: Any..., separator: String = " ", terminator: String = "\n", level: Level = .debug) {
54 excute(level: level) {
56 Swift.debugPrint(Args(args: items, separator: separator), separator: separator, terminator: terminator)
60 class func dump<T>(_ value: T, name: String? = nil, indent: Int = 0, maxDepth: Int = Int.max, maxItems: Int = Int.max) -> T {
63 return Swift.dump(value, name: name, indent: indent, maxDepth: maxDepth, maxItems: maxItems)
69 class func excute(level: Level, f: () -> Void) {
71 if UserDefaults.standard[.degugPrintLevel].higher(other: level) {