Skip to content

Commit

Permalink
IOS-3273 Keep logger configured from start
Browse files Browse the repository at this point in the history
  • Loading branch information
tureck1y committed Mar 23, 2023
1 parent 032e70c commit ef6cbc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TangemSdk/TangemSdk/Common/Core/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct Config {
public var cardIdDisplayFormat: CardIdDisplayFormat = .full

/// Logger configuration
public var logConfig: Log.Config = .debug
public var logConfig: Log.Config = .default

/// ScanTask or scanCard method in TangemSdk class will use this mode to attest the card
public var attestationMode: AttestationTask.Mode = .normal
Expand Down
10 changes: 7 additions & 3 deletions TangemSdk/TangemSdk/Common/Log/Log.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import Foundation
private let logger = Log()

public class Log {
public static var config: Log.Config = .verbose {
public static var config: Config = .default {
didSet {
logger.logLevel = config.logLevel
logger.loggers = config.loggers
}
}

private(set) var logLevel: [Log.Level] = []
private(set) var logLevel: [Log.Level] = Log.config.logLevel

private(set) var loggers: [TangemSdkLogger] = []
private(set) var loggers: [TangemSdkLogger] = Log.config.loggers

fileprivate init() {}

public static func warning<T>(_ message: @autoclosure () -> T) {
logger.logInternal(message(), level: .warning)
Expand Down Expand Up @@ -136,6 +138,8 @@ public extension Log {
case verbose
case custom(logLevel: [Log.Level],
loggers: [TangemSdkLogger] = [ConsoleLogger()])

static var `default`: Log.Config = .debug

internal var logLevel: [Log.Level] {
switch self {
Expand Down

0 comments on commit ef6cbc1

Please sign in to comment.