本文整理匯總了TypeScript中nightingale-logger.debug函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug函數的具體用法?TypeScript debug怎麽用?TypeScript debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了debug函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
(stopEmitSubscribe: UnsubscribeEmitOnConnectCallback) => {
_stopEmitSubscribeOnConnect = stopEmitSubscribe;
logger.debug('subscribed', {
resourceName: this.client.resourceName,
key: this.key,
});
},
示例2: fetch
fetch(onFulfilled?: (value: any) => any): Promise<any> {
logger.debug('fetch', {
resourceName: this.client.resourceName,
key: this.key,
});
return this.client
.send('fetch', [this.key, this.params, undefined])
.then(onFulfilled);
}
示例3: _subscribe
_subscribe(callback: Callback, _includeInitial = false): SubscribeReturn {
const eventName = `subscribe:${this.client.resourceName}.${this.key}`;
logger.debug('subscribe', { eventName });
const listener = (err: Error | null, result?: string) => {
const decodedResult = result && decode(result);
if (!PRODUCTION) logger.debug(eventName, { result, decodedResult });
callback(err, decodedResult);
};
this.client.on(eventName, listener);
let _stopEmitSubscribeOnConnect: UnsubscribeEmitOnConnectCallback;
let promise: Promise<void> | undefined = this.client
.emitSubscribe(_includeInitial ? 'fetchAndSubscribe' : 'subscribe', [
this.key,
this.params,
eventName,
])
.then(
(stopEmitSubscribe: UnsubscribeEmitOnConnectCallback) => {
_stopEmitSubscribeOnConnect = stopEmitSubscribe;
logger.debug('subscribed', {
resourceName: this.client.resourceName,
key: this.key,
});
},
(err: Error) => {
this.client.off(eventName, listener);
throw err;
},
);
const stop = () => {
if (!promise) return;
promise.then(() => {
logger.debug('unsubscribe', {
resourceName: this.client.resourceName,
key: this.key,
});
_stopEmitSubscribeOnConnect();
this.client.send('unsubscribe', [this.key]);
promise = undefined;
this.client.off(eventName, listener);
});
};
return {
cancel: stop,
stop,
then: (cb) => Promise.resolve(promise).then(cb),
};
}
示例4: send
send(type: string, value: any[]) {
logger.debug('emit', { type, value });
if (this.websocket.isDisconnected()) {
throw new Error('Websocket is not connected');
}
if (!this.resourceName) {
throw new Error('Invalid resourceName');
}
return this.websocket
.emit('resource', {
type,
resourceName: this.resourceName,
json: encode(value),
})
.then((result: any) => result && decode(result));
}
示例5: decode
const listener = (err: Error | null, result?: string) => {
const decodedResult = result && decode(result);
if (!PRODUCTION) logger.debug(eventName, { result, decodedResult });
callback(err, decodedResult);
};