chore(@desktop/keycard): do keycard logging only if it's not a `production`
This commit is contained in:
parent
025a45d1a4
commit
3af934bee6
|
@ -60,6 +60,7 @@ QtObject:
|
|||
currentFlow: KCSFlowType
|
||||
lastReceivedKeycardData: tuple[flowType: string, flowEvent: KeycardEvent]
|
||||
setPayloadForCurrentFlow: JsonNode
|
||||
doLogging: bool
|
||||
|
||||
proc setup(self: Service) =
|
||||
self.QObject.setup
|
||||
|
@ -75,10 +76,15 @@ QtObject:
|
|||
result.threadpool = threadpool
|
||||
result.closingApp = false
|
||||
result.currentFlow = KCSFlowType.NoFlow
|
||||
result.doLogging = false
|
||||
if not defined(production):
|
||||
result.doLogging = true
|
||||
|
||||
proc init*(self: Service) =
|
||||
if self.doLogging:
|
||||
debug "init keycard using ", pairingsJson=status_const.KEYCARDPAIRINGDATAFILE
|
||||
let initResp = keycard_go.keycardInitFlow(status_const.KEYCARDPAIRINGDATAFILE)
|
||||
if self.doLogging:
|
||||
debug "initialization response: ", initResp
|
||||
|
||||
proc processSignal(self: Service, signal: string) =
|
||||
|
@ -89,6 +95,7 @@ QtObject:
|
|||
error "Invalid signal received", data = signal
|
||||
return
|
||||
|
||||
if self.doLogging:
|
||||
debug "keycard_signal", response=signal
|
||||
|
||||
var typeObj, eventObj: JsonNode
|
||||
|
@ -125,16 +132,19 @@ QtObject:
|
|||
proc startFlow(self: Service, payload: JsonNode) =
|
||||
self.updateLocalPayloadForCurrentFlow(payload, cleanBefore = true)
|
||||
let response = keycard_go.keycardStartFlow(self.currentFlow.int, $payload)
|
||||
if self.doLogging:
|
||||
debug "keycardStartFlow", currentFlow=self.currentFlow.int, payload=payload, response=response
|
||||
|
||||
proc resumeFlow(self: Service, payload: JsonNode) =
|
||||
self.updateLocalPayloadForCurrentFlow(payload)
|
||||
let response = keycard_go.keycardResumeFlow($payload)
|
||||
if self.doLogging:
|
||||
debug "keycardResumeFlow", currentFlow=self.currentFlow.int, payload=payload, response=response
|
||||
|
||||
proc cancelCurrentFlow*(self: Service) =
|
||||
let response = keycard_go.keycardCancelFlow()
|
||||
self.currentFlow = KCSFlowType.NoFlow
|
||||
if self.doLogging:
|
||||
debug "keycardCancelFlow", currentFlow=self.currentFlow.int, response=response
|
||||
|
||||
proc generateRandomPUK*(self: Service): string =
|
||||
|
@ -144,6 +154,7 @@ QtObject:
|
|||
proc onTimeout(self: Service, response: string) {.slot.} =
|
||||
if(self.closingApp or self.currentFlow == KCSFlowType.NoFlow):
|
||||
return
|
||||
if self.doLogging:
|
||||
debug "onTimeout, about to start flow: ", currentFlow=self.currentFlow
|
||||
self.startFlow(self.setPayloadForCurrentFlow)
|
||||
|
||||
|
|
Loading…
Reference in New Issue