53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
//
|
|
// SentryLogger.swift
|
|
// Privado
|
|
//
|
|
// Created by Juraldinio on 11/13/19.
|
|
// Copyright © 2019 Omicronmedia. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Sentry
|
|
|
|
final class SentryLogger: ErrorCometLoggerProtocol {
|
|
|
|
private enum Constants {
|
|
#if os(iOS)
|
|
static let dsn = "https://168a9c7234b34859981b49262d022f30@sentry.privado.io/10"
|
|
#else
|
|
static let dsn = "https://87da46d8f6ba4d029a047dd45669d94b@sentry.privado.io/3"
|
|
#endif
|
|
}
|
|
|
|
var type: CometLoggerType = .crash
|
|
|
|
public var isActive = true
|
|
|
|
init() {
|
|
|
|
SentrySDK.start { options in
|
|
options.dsn = Constants.dsn
|
|
options.logLevel = .verbose
|
|
}
|
|
}
|
|
|
|
// MARK: - ErrorCometLoggerProtocol
|
|
|
|
func record(error: Error) {
|
|
guard self.isActive else { return }
|
|
self.record(error: error, userInfo: nil, secured: nil)
|
|
}
|
|
|
|
func record(error: Error, userInfo: [String: Any]?, secured: [String: Any]?) {
|
|
guard self.isActive else { return }
|
|
let event = Event(level: .error)
|
|
event.message = error.localizedDescription
|
|
|
|
if let info = userInfo {
|
|
event.extra = info
|
|
}
|
|
|
|
SentrySDK.capture(event: event)
|
|
}
|
|
}
|