-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
109 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,64 @@ | ||
import Foundation | ||
@_implementationOnly import MapboxCommon_Private.MBXLog_Internal | ||
|
||
internal struct Log { | ||
/// A logging utility with MapboxCommon backend by default. | ||
@_spi(Logging) public struct Log { | ||
private typealias Logger = MapboxCommon_Private.Log | ||
|
||
private static func logCategory(_ additionalCategory: String?) -> String { | ||
let logPrefix = "maps-ios" | ||
guard let additionalCategory = additionalCategory else { | ||
guard let additionalCategory = additionalCategory, !additionalCategory.isEmpty else { | ||
return logPrefix | ||
} | ||
return "\(logPrefix)/\(additionalCategory)" | ||
} | ||
|
||
internal static func debug(forMessage message: String, category: String? = nil) { | ||
Logger.debug(forMessage: message, category: logCategory(category)) | ||
/// Log a debug message. | ||
@_spi(Logging) public static func debug(_ message: String, category: Category? = nil) { | ||
Logger.debug(forMessage: message, category: logCategory(category?.rawValue)) | ||
} | ||
|
||
internal static func info(forMessage message: String, category: String? = nil) { | ||
Logger.info(forMessage: message, category: logCategory(category)) | ||
/// Log an info message. | ||
@_spi(Logging) public static func info(_ message: String, category: Category? = nil) { | ||
Logger.info(forMessage: message, category: logCategory(category?.rawValue)) | ||
} | ||
|
||
internal static func warning(forMessage message: String, category: String? = nil) { | ||
Logger.warning(forMessage: message, category: logCategory(category)) | ||
/// Log a warning message. | ||
@_spi(Logging) public static func warning(_ message: String, category: Category? = nil) { | ||
Logger.warning(forMessage: message, category: logCategory(category?.rawValue)) | ||
} | ||
|
||
internal static func error(forMessage message: String, category: String? = nil) { | ||
Logger.error(forMessage: message, category: logCategory(category)) | ||
/// Log an error message. | ||
@_spi(Logging) public static func error(_ message: String, category: Category? = nil) { | ||
Logger.error(forMessage: message, category: logCategory(category?.rawValue)) | ||
} | ||
} | ||
|
||
extension Log { | ||
@_spi(Logging) public struct Category: RawRepresentable, ExpressibleByStringLiteral { | ||
public let rawValue: String | ||
|
||
public init(rawValue: String) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
init(_ value: String) { | ||
self.rawValue = value | ||
} | ||
|
||
public init(stringLiteral value: StringLiteralType) { | ||
self.rawValue = value | ||
} | ||
|
||
public init(unicodeScalarLiteral value: String) { | ||
self.rawValue = value | ||
} | ||
|
||
public init(extendedGraphemeClusterLiteral value: String) { | ||
self.rawValue = value | ||
} | ||
|
||
static let `default` = Category("") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.