-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(logging): Logging logic (#248)
Simplifies the logging functionality in the library. - Each target has an internal Log structure with its own instance of Logger - Logs is a public structure exposing the static logSeverityLevel property to a library user. It emits the notification with log severity level to notifiy all internal Log structures.
- Loading branch information
1 parent
bb37ec0
commit 25d5e3e
Showing
39 changed files
with
4,371 additions
and
4,343 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// InstantSearchLog.swift | ||
// InstantSearch | ||
// | ||
// Created by Vladislav Fitc on 31/01/2020. | ||
// | ||
|
||
import Foundation | ||
import Logging | ||
#if !InstantSearchCocoaPods | ||
import struct InstantSearchInsights.Logs | ||
import protocol InstantSearchInsights.LogCollectable | ||
#endif | ||
|
||
struct InstantSearchLog: LogCollectable { | ||
|
||
static var logger: Logging.Logger = { | ||
NotificationCenter.default.addObserver(forName: Logs.logLevelChangeNotficationName, object: nil, queue: .main) { notification in | ||
if let logLevel = notification.userInfo?["logLevel"] as? LogLevel { | ||
InstantSearchLog.logger.logLevel = logLevel.swiftLogLevel | ||
} | ||
} | ||
var logger = Logging.Logger(label: "InstantSearch") | ||
logger.logLevel = Logs.logSeverityLevel.swiftLogLevel | ||
return logger | ||
}() | ||
|
||
static func missingHitsSourceWarning() { | ||
warning("Missing hits source") | ||
} | ||
|
||
static func missingCellConfiguratorWarning(forSection section: Int) { | ||
logger.warning("No cell configurator found for section \(section)") | ||
} | ||
|
||
static func missingClickHandlerWarning(forSection section: Int) { | ||
logger.warning("No click handler found for section \(section)") | ||
} | ||
|
||
static func error(_ error: Error) { | ||
logger.error("\(error)") | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.