Add a logging library #3204

pull/3217/head
Vladyslav shepitko 3 years ago
parent 9b16b37b8f
commit 4f6b3e40e3
  1. 62
      AlphaWallet/Core/Helpers/RemoteLogger.swift
  2. 8
      AlphaWallet/Core/Initializers/MigrationInitializer.swift
  3. 4
      AlphaWallet/Tokens/ViewControllers/Collectibles/Coordinators/TokensCardCollectionCoordinator.swift
  4. 2
      AlphaWallet/Transactions/Coordinators/SingleChainTransactionEtherscanDataCoordinator.swift
  5. 4
      AlphaWalletTests/Redeem/CreateRedeemTests.swift
  6. 4
      AlphaWalletTests/Redeem/EventsRestTest.swift
  7. 1
      Podfile
  8. 3
      Podfile.lock

@ -2,6 +2,35 @@
import Foundation
import PaperTrailLumberjack
import CocoaLumberjack
func debug(_ message: Any, _ loggger: Logger = DDLogger.instance) {
loggger.debug(message)
}
func info(_ message: Any, _ loggger: Logger = DDLogger.instance) {
loggger.info(message)
}
func warn(_ message: Any, _ loggger: Logger = DDLogger.instance) {
loggger.warn(message)
}
func verbose(_ message: Any, _ loggger: Logger = DDLogger.instance) {
loggger.verbose(message)
}
func error(_ message: Any, _ loggger: Logger = DDLogger.instance) {
loggger.error(message)
}
protocol Logger {
func debug(_ message: Any)
func info(_ message: Any)
func warn(_ message: Any)
func verbose(_ message: Any)
func error(_ message: Any)
}
class RemoteLogger {
private let isActive: Bool
@ -42,3 +71,36 @@ class RemoteLogger {
}
}
}
final class DDLogger: Logger {
static let instance = DDLogger()
init() {
let fileLogger = DDFileLogger(logFileManager: DDLogFileManagerDefault())
fileLogger.rollingFrequency = 60 * 60 * 24
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
DDLog.add(DDASLLogger.sharedInstance)
DDLog.add(fileLogger, with: .info)
}
func debug(_ message: Any) {
DDLogDebug(message)
}
func info(_ message: Any) {
DDLogInfo(message)
}
func warn(_ message: Any) {
DDLogWarn(message)
}
func verbose(_ message: Any) {
DDLogVerbose(message)
}
func error(_ message: Any) {
DDLogError(message)
}
}

@ -119,11 +119,9 @@ extension MigrationInitializer {
func oneTimeCreationOfOneDatabaseToHoldAllChains(assetDefinitionStore: AssetDefinitionStore) {
let migration = self
#if DEBUG
print(migration.config.fileURL!)
print(migration.config.fileURL!.deletingLastPathComponent())
#endif
debug(migration.config.fileURL!)
debug(migration.config.fileURL!.deletingLastPathComponent())
let exists: Bool
if let path = migration.config.fileURL?.path {

@ -260,11 +260,11 @@ extension TokensCardCollectionCoordinator: TokensCardCollectionViewControllerDel
}
func didTap(transaction: TransactionInstance, in viewController: TokensCardCollectionViewController) {
print("didTap(transaction")
debug("didTap(transaction")
}
func didTap(activity: Activity, in viewController: TokensCardCollectionViewController) {
print("didTap(activity")
debug("didTap(activity")
}
func didSelectAssetSelection(in viewController: TokensCardCollectionViewController) {

@ -58,7 +58,7 @@ class SingleChainTransactionEtherscanDataCoordinator: SingleChainTransactionData
}
deinit {
print("\(self).deinit")
debug("\(self).deinit")
}
func stopTimers() {

@ -21,8 +21,8 @@ class CreateRedeemTests: XCTestCase {
let signature = try! keyStore.signMessageData(data!, for: account.dematerialize())
//message and signature is to go in qr code
print("message: " + message)
print(try! "signature: " + signature.dematerialize().hexString)
debug("message: " + message)
debug(try! "signature: " + signature.dematerialize().hexString)
//TODO no test?
}
}

@ -20,10 +20,10 @@ class EventsRestTest: XCTestCase {
// EventsRest().getEvents { result in
// switch result {
// case .success(let events):
// print(events)
// debug(events)
// expectation.fulfill()
// case .failure(let error):
// print(error)
// debug(error)
// }
// }
// wait(for: expectations, timeout: 10)

@ -39,6 +39,7 @@ target 'AlphaWallet' do
pod 'AssistantKit'
# pod 'AWSCognito'
pod 'Charts'
pod 'CocoaLumberjack'
target 'AlphaWalletTests' do
inherit! :search_paths

@ -124,6 +124,7 @@ DEPENDENCIES:
- BigInt (~> 3.1)
- BlockiesSwift
- Charts
- CocoaLumberjack
- CryptoSwift (~> 1.0)
- Eureka (from `https://github.com/xmartlabs/Eureka.git`, commit `5c54e2607632ce586010e50e91d9adcb6bb3909e`)
- iOSSnapshotTestCase
@ -304,6 +305,6 @@ SPEC CHECKSUMS:
WalletConnectSwift: cd5e056cec5a2f44e92b8595199e7f2f9f0bd92d
web3swift: 06118d4c4edc801444aaa995bbbddeda176b97ef
PODFILE CHECKSUM: e15f876f8b24ff3243a6307c505701c18be2abc3
PODFILE CHECKSUM: 5432a4ca2e15639caf3dd8bcd7270f844451c22a
COCOAPODS: 1.10.1

Loading…
Cancel
Save