feat: basic logger
This commit is contained in:
parent
e2f9b481ab
commit
37818d3153
|
|
@ -0,0 +1,52 @@
|
|||
import os
|
||||
|
||||
public struct TILogger: LoggerRepresentable {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
public static let defaultLogger = TILogger(subsystem: .defaultSubsystem ?? "", category: .pointsOfInterest)
|
||||
|
||||
public let logInfo: OSLog
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
public init(subsystem: String, category: String) {
|
||||
self.logInfo = .init(subsystem: subsystem, category: category)
|
||||
}
|
||||
|
||||
public init(subsystem: String, category: OSLog.Category) {
|
||||
self.logInfo = .init(subsystem: subsystem, category: category)
|
||||
}
|
||||
|
||||
// MARK: - LoggerRepresentable
|
||||
|
||||
public func log(_ message: StaticString, log: OSLog?, type: OSLogType, _ arguments: CVarArg...) {
|
||||
os_log(message, log: log ?? logInfo, type: type, arguments)
|
||||
}
|
||||
|
||||
// MARK: - Public methods
|
||||
|
||||
public func verbose(_ message: StaticString, _ arguments: CVarArg...) {
|
||||
self.log(message, log: logInfo, type: .default, arguments)
|
||||
}
|
||||
|
||||
public func info(_ message: StaticString, _ arguments: CVarArg...) {
|
||||
self.log(message, log: logInfo, type: .info, arguments)
|
||||
}
|
||||
|
||||
public func debug(_ message: StaticString, _ arguments: CVarArg...) {
|
||||
self.log(message, log: logInfo, type: .debug, arguments)
|
||||
}
|
||||
|
||||
public func error(_ message: StaticString, _ arguments: CVarArg...) {
|
||||
self.log(message, log: logInfo, type: .error, arguments)
|
||||
}
|
||||
|
||||
public func fault(_ message: StaticString, _ arguments: CVarArg...) {
|
||||
self.log(message, log: logInfo, type: .fault, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
private extension String {
|
||||
static let defaultSubsystem = Bundle.main.bundleIdentifier
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import os
|
||||
|
||||
public protocol LoggerRepresentable {
|
||||
func log(_ message: StaticString, log: OSLog?, type: OSLogType, _ arguments: CVarArg...)
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TILogging'
|
||||
s.version = '1.27.0'
|
||||
s.summary = 'Logging API'
|
||||
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru' }
|
||||
s.source = { :git => 'https://github.com/TouchInstinct/LeadKit.git', :tag => s.version.to_s }
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.swift_versions = ['5.3']
|
||||
|
||||
s.source_files = s.name + '/Sources/**/*'
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue