-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional debug logs for better traceability #203
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -75,7 +79,14 @@ class EffectDispatcher<Invocation: AnyEffectInvocation, Event, Dependencies>: Di | |||
storageId id: String, | |||
notify listener: DispatcherListener<Event> | |||
) { | |||
effectsCache.put(effect: effect, with: id) | |||
effectsCache.put( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
let currentStateDescr = String(describing: currentState) | ||
let newStateDescr = String(describing: newState) | ||
|
||
PubNub.log.debug("Exiting \(currentStateDescr)", category: LogCategory.eventEngine.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
return "No URL found in request" | ||
} | ||
|
||
var debugString = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
|
||
switch encryptionResult { | ||
case .success: | ||
PubNub.log.debug("Data encrypted successfully", category: LogCategory.crypto.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
|
||
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) | ||
extension Logger { | ||
static var subsystem: String { "com.pubnub"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -96,11 +98,17 @@ final class Request { | |||
self.requestOperator = MultiplexRequestOperator(operators: operators) | |||
self.delegate = delegate | |||
|
|||
PubNub.log.debug("Request Created \(requestID) on \(router)") | |||
PubNub.log.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -254,14 +266,29 @@ final class Request { | |||
} | |||
|
|||
func didResume(_ task: URLSessionTask) { | |||
sessionStream?.emitRequest(self, didResume: task) | |||
PubNub.log.debug( | |||
"Sending HTTP request \(task.requestDescr()) for \(requestID)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
.debug, | ||
category: category, | ||
message: message(), | ||
date: date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -50,6 +50,10 @@ class EffectDispatcher<Invocation: AnyEffectInvocation, Event, Dependencies>: Di | |||
notify listener: DispatcherListener<Event> | |||
) { | |||
invocations.forEach { | |||
PubNub.log.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be some trace
level because level of verbosity would be insane on working Event Engine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the currently exposed interface wrt LogType
:
public struct LogType: OptionSet, Equatable, Hashable, Sendable {
public let rawValue: UInt32
// Reserverd Log Types
public static let none = LogType([])
public static let debug = LogType(rawValue: 1 << 0)
public static let info = LogType(rawValue: 1 << 1)
public static let event = LogType(rawValue: 1 << 2)
public static let warn = LogType(rawValue: 1 << 3)
public static let error = LogType(rawValue: 1 << 4)
public static let log = LogType(rawValue: 1 << 31)
public static let all = LogType(rawValue: UInt32.max)
public init(rawValue: UInt32) {
self.rawValue = rawValue
}
}
I see two possibilities:
- Treating
debug
level as atrace
level. However, this might not be what you expect - Add a new
trace
type with the following value(1 << 5)
to not to break values introduced before
Regarding the second option, we could then replace all the PubNub.log.debug
occurrences I introduced in the scope of this PR with PubNub.log.trace
. Which option do you prefer?
let currentStateDescr = String(describing: currentState) | ||
let newStateDescr = String(describing: newState) | ||
|
||
PubNub.log.debug("Exiting \(currentStateDescr)", category: LogCategory.eventEngine.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious about performance hit because of formatting which won't be used if logger is off. Should we have some kind of closure in this function which conditionally will be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how exactly it should work under the hood. The message
parameter for the PubNub.log.debug
and simillar methods as well uses autoclosure, which means that a value evaluation will be deferred if needed. Anyway, I will double check it if it works as expected and let you know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
feat(logger): add
OSLogWriter
as the recommendedLogWriter
to usefeat(logger): refine
LogWriter
protocol signature to support build-inLogger
from theos
frameworkfeat(logger): enhance object descriptions with
CustomStringConvertible
feat(logger): add explanatory documentation for debug-level logging messages