本文整理汇总了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);
};