当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript nightingale-logger.warn函数代码示例

本文整理汇总了TypeScript中nightingale-logger.warn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript warn函数的具体用法?TypeScript warn怎么用?TypeScript warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了warn函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Error

 connection.on('timeout', () => {
   logger.warn('timeout', { connectionString });
   this.connectionFailed = true;
   this.getConnection = () => {
     throw new Error('MongoDB connection timeout');
   };
 });
开发者ID:liwijs,项目名称:liwi,代码行数:7,代码来源:MongoConnection.ts

示例2:

 connection.on('error', (err) => {
   logger.warn('error', { connectionString, err });
 });
开发者ID:liwijs,项目名称:liwi,代码行数:3,代码来源:MongoConnection.ts

示例3: decode

      (
        { type, resourceName, json }: EventResourceParams,
        callback: Callback,
      ): void => {
        try {
          const value = json && decode(json);

          switch (type) {
            case 'cursor toArray': {
              const resource = resourcesService.getCursorResource(resourceName);
              resourcesService
                .createCursor(resource, socket.user, value)
                .then((cursor) => cursor.toArray())
                .then((results) => callback(null, encode(results)))
                .catch((err) => {
                  logger.error(type, err);
                  callback(err.message);
                });
              break;
            }

            case 'fetch':
            case 'subscribe':
            case 'fetchAndSubscribe':
              try {
                const resource = resourcesService.getServiceResource(
                  resourceName,
                );
                logger.info('resource', { type, resourceName, value });

                const [key, params, eventName] = value;

                if (!key.startsWith('query')) {
                  throw new Error('Invalid query key');
                }

                const query = resource.queries[key](params, socket.user);

                if (type === 'fetch') {
                  query
                    .fetch((result: any) =>
                      callback(null, result && encode(result)),
                    )
                    .catch((err: any) => {
                      logger.error(type, { err });
                      callback(err.message || err);
                    });
                } else {
                  const watcherKey = `${resourceName}__${key}`;
                  if (openWatchers.has(watcherKey)) {
                    logger.warn(
                      'Already have a watcher for this key. Cannot add a new one',
                      { watcherKey, key },
                    );
                    callback(
                      'Already have a watcher for this key. Cannot add a new one',
                    );
                    return;
                  }
                  const watcher = query[type](
                    (err: Error | null, result: any) => {
                      if (err) {
                        logger.error(type, { err });
                      }

                      socket.emit(eventName, err, result && encode(result));
                    },
                  );

                  watcher.then(
                    () => callback(null),
                    (err: Error) => {
                      logger.error(type, { err });
                      callback(err.message);
                    },
                  );

                  const subscribeHook =
                    resource.subscribeHooks && resource.subscribeHooks[key];
                  openWatchers.set(watcherKey, { watcher, subscribeHook });
                  if (subscribeHook) {
                    subscribeHook.subscribed(socket.user);
                  }
                }
              } catch (err) {
                logger.error(type, { err });
                callback(err.message || err);
              }
              break;

            case 'unsubscribe': {
              const [key] = value;
              const watcherKey = `${resourceName}__${key}`;
              const watcherAndSubscribeHook = openWatchers.get(watcherKey);
              if (!watcherAndSubscribeHook) {
                logger.warn('tried to unsubscribe non existing watcher', {
                  key,
                });
                return callback(null);
              }
//.........这里部分代码省略.........
开发者ID:liwijs,项目名称:liwi,代码行数:101,代码来源:index.ts


注:本文中的nightingale-logger.warn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。