當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript logger.log類代碼示例

本文整理匯總了TypeScript中@toba/logger.log的典型用法代碼示例。如果您正苦於以下問題:TypeScript log類的具體用法?TypeScript log怎麽用?TypeScript log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了log類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: internalError

/**
 * Render status `500` page.
 */
function internalError(res: Response, err?: Error): void {
   if (is.value(err)) {
      log.error(err);
   }
   res.statusCode = HttpStatus.InternalError;
   res.render(Page.InternalError, { title: 'Oops', config });
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:10,代碼來源:view.ts

示例2: sendFromCache

function sendFromCache(res: Response, slug: string): boolean {
   if (config.cache.views) {
      const item = cache.get(slug);

      if (item !== null) {
         // send cached item directly
         writeItemToResponse(res, item);
         return true;
      } else {
         log.info(`"${slug}" not cached`, { slug });
      }
   } else {
      log.warn(`Caching disabled for ${slug}`, { slug });
   }
   return false;
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:16,代碼來源:view.ts

示例3: compact

export function compact(text: string, options?: uglify.MinifyOptions): string {
   const output = uglify.minify(text, options);
   if (output.error) {
      log.error(output.error);
      return text;
   } else {
      return output.code;
   }
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:9,代碼來源:view.ts

示例4: reject

 compress.gzip(Buffer.from(text), (err: Error, buffer: Buffer) => {
    if (is.value(err)) {
       reject(err);
       log.error(err, { slug: key });
    } else {
       resolve({
          buffer,
          eTag: key + '_' + new Date().getTime().toString(),
          type
       });
    }
 });
開發者ID:Trail-Image,項目名稱:blog,代碼行數:12,代碼來源:view.ts

示例5: createWebService

async function createWebService() {
   const app = Express();
   const port = process.env['PORT'] || 3000;

   log.info(
      `Starting ${
         config.isProduction ? 'production' : 'development'
      } application`
   );

   defineViews(app);

   if (false) {
      //config.needsAuth) {
      // must authenticate before normal routes are available
      route.authentication(app);
      app.listen(port);
      log.info(`Listening for authentication on port ${port}`);
   } else {
      if (config.requireSSL) {
         app.use(requireSSL);
      }
      app.use(blockSpamReferers);
      // https://github.com/expressjs/compression/blob/master/README.md
      app.use(compress());
      app.use(Express.static(path.join(root, 'public')));

      await blog.load();

      if (blog.loaded) {
         // blog must be loaded before routes are defined
         route.standard(app);
         app.listen(port);
         log.info(`Listening on port ${port}`);
      } else {
         log.error('Blog data failed to load. Stopping application.');
      }
   }
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:39,代碼來源:app.ts

示例6: postFeed

export function postFeed(req: Request, res: Response) {
   if (!blog.postInfoLoaded) {
      if (rssRetries >= MAX_RSS_RETRIES) {
         log.error(`Unable to load blog after ${MAX_RSS_RETRIES} tries`);
         view.notFound(req, res);
         // reset tries so page can be refreshed
         rssRetries = 0;
      } else {
         rssRetries++;
         log.error(
            `Blog posts not ready when creating RSS feed — attempt ${rssRetries}`
         );
         setTimeout(() => {
            postFeed(req, res);
         }, 1000);
      }
      return;
   }

   res.set(Header.Content.Type, MimeType.XML);
   res.write(render(blog));
   res.end();
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:23,代碼來源:rss.ts

示例7:

 .catch(err => {
    log.error(err, { photoID });
    view.notFound(req, res);
 });
開發者ID:Trail-Image,項目名稱:blog,代碼行數:4,代碼來源:post.ts

示例8:

 post.gpx(res).catch(err => {
    log.error(err);
    res.removeHeader(Header.Content.Type);
    res.removeHeader(Header.Content.Disposition);
    view.notFound(req, res);
 });
開發者ID:Trail-Image,項目名稱:blog,代碼行數:6,代碼來源:map.ts

示例9: notFound

export function notFound(req: Request, res: Response): void {
   const ip = clientIP(req);
   log.warn(`${req.originalUrl} not found for ${ip}`, { clientIP: ip });
   res.statusCode = HttpStatus.NotFound;
   res.render(Page.NotFound, { title: 'Page Not Found', config });
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:6,代碼來源:view.ts


注:本文中的@toba/logger.log類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。