1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
@_exported import CocoaLumberjack #if SWIFT_PACKAGE import CocoaLumberjackSwiftSupport #endif
extension DDLogFlag { public static func from(_ logLevel: DDLogLevel) -> DDLogFlag { return DDLogFlag(rawValue: logLevel.rawValue) }
public init(_ logLevel: DDLogLevel) { self = DDLogFlag(rawValue: logLevel.rawValue) }
public func toLogLevel() -> DDLogLevel { if let ourValid = DDLogLevel(rawValue: rawValue) { return ourValid } else { if contains(.verbose) { return .verbose } else if contains(.debug) { return .debug } else if contains(.info) { return .info } else if contains(.warning) { return .warning } else if contains(.error) { return .error } else { return .off } } } }
public var dynamicLogLevel = DDLogLevel.all
@inlinable public func resetDynamicLogLevel() { dynamicLogLevel = .all }
@available(*, deprecated, message: "Please use dynamicLogLevel", renamed: "dynamicLogLevel") public var defaultDebugLevel: DDLogLevel { get { return dynamicLogLevel } set { dynamicLogLevel = newValue } }
@available(*, deprecated, message: "Please use resetDynamicLogLevel", renamed: "resetDynamicLogLevel") public func resetDefaultDebugLevel() { resetDynamicLogLevel() }
public var asyncLoggingEnabled = true
@inlinable public func _DDLogMessage(_ message: @autoclosure () -> Any, level: DDLogLevel, flag: DDLogFlag, context: Int, file: StaticString, function: StaticString, line: UInt, tag: Any?, asynchronous: Bool, ddlog: DDLog) { if level.rawValue & flag.rawValue != 0 && dynamicLogLevel.rawValue & flag.rawValue != 0 { let logMessage = DDLogMessage(message: String(describing: message()), level: level, flag: flag, context: context, file: String(describing: file), function: String(describing: function), line: line, tag: tag, options: [.copyFile, .copyFunction], timestamp: nil) ddlog.log(asynchronous: asynchronous, message: logMessage) } }
@inlinable public func DDLogDebug(_ message: @autoclosure () -> Any, level: DDLogLevel = .debug, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = asyncLoggingEnabled, ddlog: DDLog = .sharedInstance) { _DDLogMessage(message(), level: level, flag: .debug, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog) }
@inlinable public func DDLogInfo(_ message: @autoclosure () -> Any, level: DDLogLevel = .info, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = asyncLoggingEnabled, ddlog: DDLog = .sharedInstance) { _DDLogMessage(message(), level: level, flag: .info, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog) }
@inlinable public func DDLogWarn(_ message: @autoclosure () -> Any, level: DDLogLevel = DDLogLevel.warning, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = asyncLoggingEnabled, ddlog: DDLog = .sharedInstance) { _DDLogMessage(message(), level: level, flag: .warning, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog) }
@inlinable public func DDLogVerbose(_ message: @autoclosure () -> Any, level: DDLogLevel = .verbose, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = asyncLoggingEnabled, ddlog: DDLog = .sharedInstance) { _DDLogMessage(message(), level: level, flag: .verbose, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog) }
@inlinable public func DDLogError(_ message: @autoclosure () -> Any, level: DDLogLevel = .error, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = false, ddlog: DDLog = .sharedInstance) { _DDLogMessage(message(), level: level, flag: .error, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog) }
public func currentFileName(_ fileName: StaticString = #file) -> String { var str = String(describing: fileName) if let idx = str.range(of: "/", options: .backwards)?.upperBound { str = String(str[idx...]) } if let idx = str.range(of: ".", options: .backwards)?.lowerBound { str = String(str[..<idx]) } return str }
@available(*, deprecated, message: "Please use currentFileName", renamed: "currentFileName") public func CurrentFileName(_ fileName: StaticString = #file) -> String { return currentFileName(fileName) }
|