Skip to content

Commit

Permalink
🦞 Fix: Issues from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Shamorkin committed Mar 18, 2022
1 parent 1c06290 commit e350ac6
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ extension SafariProtection {
return true
} onCbReloaded: { [weak self] error in
guard let self = self else {
LOG.error(".onCbReloaded; self is missing!")
LOG.error("modifyRule.onCbReloaded; self is missing!")
DispatchQueue.main.async { onCbReloaded?(CommonError.missingSelf) }
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class LoggerFactory: NSObject {
public class LoggerFactory : NSObject {

@objc
public static func getLoggerWrapper(_ label: String) -> LoggerWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import SwiftyBeaver

/// Logger with specified label
public final class LoggerWrapper: NSObject {
public final class LoggerWrapper : NSObject {
@objc
let label: String

Expand Down
4 changes: 2 additions & 2 deletions AdguardExtension/ActionExtension/ContextProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct Context {
let isJsInjectSupported: Bool
}

private let LOG = LoggerFactory.getLoggerWrapper(ContextProvider.self)

/// This object is responsible for providing extension context
/// It transforms `NSExtensionContext` into normal readable object `Context`

private let LOG = LoggerFactory.getLoggerWrapper(ContextProvider.self)

struct ContextProvider {

enum ContextError: Error, CustomDebugStringConvertible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// along with Adguard for iOS. If not, see <http://www.gnu.org/licenses/>.
//

// Set period for minimum background fetch interval
import SharedAdGuardSDK

private let LOG = LoggerFactory.getLoggerWrapper(AppDelegate.self)

// Set period for minimum background fetch interval
extension AppDelegate {
static func setBackgroundFetchInterval(_ interval: TimeInterval) {
guard interval >= UIApplication.backgroundFetchIntervalMinimum else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ extension AppDelegate: IURLSchemeExecutor {
}

func openUserRulesRedirectController(for action: UserRulesRedirectAction) -> Bool {
LOG.info("openUserRulesRedirectController with action = \(action)")
LOG.info("Open UserRulesRedirectController with action = \(action)")
return self.presentUserRulesRedirectController(for: action)
}

func openMainPageControllerAndTurnOnProtection(for domain: String) -> Bool {
LOG.info("openMainPageControllerAndTurnOnProtection for domain=\(domain) ")
LOG.info("Open MainPageController and turn on protection for domain=\(domain) ")
return self.presentMainPageControllerAndTurnOnProtection(for: domain)
}

func openPurchaseLicenseController() -> Bool {
LOG.info("openPurchaseLicenseController")
LOG.info("Open PurchaseLicenseController")
return self.presentPurchaseLicenseController()
}

func openAdvancedProtectionController(enableAdvancedProtection: Bool?) -> Bool {
let enabledState = enableAdvancedProtection == nil ? "nil" : "\(enableAdvancedProtection!)"
LOG.info("enabledAdvancedProtection = \(enabledState)")
LOG.info("Open AdvancedProtectionController = \(enabledState)")
return self.presentAdvancedProtectionController(enableAdvancedProtection: enableAdvancedProtection)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// along with Adguard for iOS. If not, see <http://www.gnu.org/licenses/>.
//

// Handle UserNotificationService notifications
import SharedAdGuardSDK

private let LOG = LoggerFactory.getLoggerWrapper(AppDelegate.self)

// Handle UserNotificationService notifications
extension AppDelegate {
func subscribeToUserNotificationServiceNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(showAlertNotification(notification:)), name: .showCommonAlert, object: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with Adguard for iOS. If not, see <http://www.gnu.org/licenses/>.
//

import SharedAdGuardSDK

private let LOG = LoggerFactory.getLoggerWrapper(OpenUserFilterControllerParser.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with Adguard for iOS. If not, see <http://www.gnu.org/licenses/>.
//

import SharedAdGuardSDK

private let LOG = LoggerFactory.getLoggerWrapper(SocialNetworkAuthParametersParser.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftyBeaver
import os.log

/// Send log messages to debug console and Console.app
class ConsoleAppDestination: BaseDestination {
class ConsoleAppDestination : BaseDestination {

override public var defaultHashValue: Int { return 3 } // We use 3 because we want that 🐣

Expand Down
2 changes: 1 addition & 1 deletion AdguardExtension/Common/Logger/LoggerManager.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import SwiftyBeaver

protocol LoggerManager: AnyObject {
protocol LoggerManager : AnyObject {

var rootLogDirectory: URL { get }

Expand Down
2 changes: 1 addition & 1 deletion AdguardExtension/Common/Logger/LoggerManagerImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftyBeaver
import AGDnsProxy

/// Manager that create os and file log destinations. Creates and stores labeled loggers
final class LoggerManagerImpl: LoggerManager {
final class LoggerManagerImpl : LoggerManager {

var rootLogDirectory: URL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os.log
// This entity is wrapper for the Apple logger system `os_log`
// Since iOS 14.0 this entity would not be used
@available(iOS, deprecated: 14, message: "We should use the `ComLog_NativeLoggerWrapperSystemLoggerImpl` class instead")
class NativeLoggerWrapperOsLogImpl: NativeLoggerWrapper {
class NativeLoggerWrapperOsLogImpl : NativeLoggerWrapper {

private static let messageTemplate: StaticString = "%{public}@"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os.log
/// This object is wrapper for the Apple logger system `Logger`
/// From iOS 14.0 Apple introduce improved API for OSLog framework; See [Logger](https://developer.apple.com/documentation/os/logger)
@available(iOS 14.0, *)
class NativeLoggerWrapperSystemLoggerImpl: NativeLoggerWrapper {
class NativeLoggerWrapperSystemLoggerImpl : NativeLoggerWrapper {

private let logger: Logger

Expand Down
3 changes: 2 additions & 1 deletion AdguardExtension/SafariWebExtension/ChunkFileReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import Foundation
import SharedAdGuardSDK

private let LOG = LoggerFactory.getLoggerWrapper(ChunkFileReader.self)

/**
`ChunkFileReader` is responsible for reading file by chunks without fully loading it to RAM,
because in `SafariWebExtension` we have a limit of 6mb and average file is about 7mb
Expand All @@ -43,7 +45,6 @@ import SharedAdGuardSDK
- Important: Don't forget to close file with `close` function after finished reading it
*/
private let LOG = LoggerFactory.getLoggerWrapper(ChunkFileReader.self)

final class ChunkFileReader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ final class SupportService: SupportServiceProtocol {
return data
}


private func getDirectoryContentUrls(_ target: URL) throws -> [URL] {
LOG.debug("Start getting content from \(target)")
if try target.resourceValues(forKeys: [.isDirectoryKey]).isDirectory == true {
Expand Down
4 changes: 2 additions & 2 deletions AdguardExtension/Tunnel/TunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import SafariAdGuardSDK
import Sentry
import AGDnsProxy

private let LOG = LoggerFactory.getLoggerWrapper(TunnelProvider.self)

/**
This object gives access to a virtual network interface
The main logic of this class is implemented in `DnsAdGuardSDK.PacketTunnelProvider`
- Seealso https://developer.apple.com/documentation/networkextension/nepackettunnelprovider
*/

private let LOG = LoggerFactory.getLoggerWrapper(TunnelProvider.self)

class TunnelProvider: PacketTunnelProvider {
static let tunnelRemoteAddress = "127.1.1.1"

Expand Down

0 comments on commit e350ac6

Please sign in to comment.