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


TypeScript util.log函數代碼示例

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


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

示例1: Date

  }, (err, stats) => {
    if (err) {
      console.error('Failed to create a production build. Reason:');
      console.error(err.message || err);
      process.exit(1);
    }

    console.log(stats.toString({
      chunks: false,
      colors: true
    }));

    const completionTime = Math.round((new Date().getTime() - startTime) / 1000 * 100) / 100;
    log('------------------------------------------');
    log(`=== Compilation and bundling completed in ${completionTime} sec.`);
    log('------------------------------------------');
    log('===== Waiting for changes... ======')
  })
開發者ID:botique-ai,項目名稱:bigg-botique,代碼行數:18,代碼來源:bundleTypescriptAndWatch.ts

示例2: bundleTypescriptAndWatch

export function bundleTypescriptAndWatch({entries}) {
  const webpackEntry = {};

  entries.forEach((entry) => {
    webpackEntry['build/' + entry.name + '/bundle'] = entry.src;
  });

  config.entry = webpackEntry;

  const compiler = webpack(config);

  console.log();
  log('------------------------------------------');
  log(`===> Starting compilation and bundling... `);
  log('------------------------------------------');

  let startTime = new Date().getTime();

  compiler['plugin']('invalid', () => {
    log('==== Change detected. Compiling... =====');
    startTime = new Date().getTime();
  });

  compiler.watch({
    poll: true
  }, (err, stats) => {
    if (err) {
      console.error('Failed to create a production build. Reason:');
      console.error(err.message || err);
      process.exit(1);
    }

    console.log(stats.toString({
      chunks: false,
      colors: true
    }));

    const completionTime = Math.round((new Date().getTime() - startTime) / 1000 * 100) / 100;
    log('------------------------------------------');
    log(`=== Compilation and bundling completed in ${completionTime} sec.`);
    log('------------------------------------------');
    log('===== Waiting for changes... ======')
  })
}
開發者ID:botique-ai,項目名稱:bigg-botique,代碼行數:44,代碼來源:bundleTypescriptAndWatch.ts

示例3: catch

                this._codecs.forEach((codec) => {
                    if (codec.context == context) {
                        let result = null;

                        try {
                            result = Hcp.decode(codec.id, this.toArrayBuffer(data), size);
                        } catch (error) {
                            util.log(JSON.stringify(error));
                            return;
                        }

                        try {
                            codec.receive(result);
                        } catch (error) {
                            util.log(JSON.stringify(error));
                        }

                        results.push(result);
                    }
                });
開發者ID:adamarvid,項目名稱:hcp,代碼行數:20,代碼來源:hcp-node.ts

示例4: apply

    // see https://github.com/tutumcloud/haproxy
    //     https://serversforhackers.com/load-balancing-with-haproxy
    /**
     * Generate config and restart haproxy
     */
    async apply() {
        util.log("Generating new haproxy configuration file...");

        const config = await this.transform(false);
        if (config) {
            fs.writeFileSync(this.configFileName, config);
        }
        else {
            shell.rm(this.configFileName);
        }

        this.proxyManager.restart();
    }
開發者ID:Zenasoft,項目名稱:vulcain-loadbalancer,代碼行數:18,代碼來源:template.ts

示例5: emitBinding

    /**
     * Emit front definition with ssl certificats list for all tenants
     * Bind on port 443 or port 80 in test mode
     */
    private async emitBinding(dryrun: boolean) {
        this.frontends.push("frontend vulcain");

        if (CONTEXT.isTest()) {
            this.frontends.push(`  bind *:80`);
            return true;
        }

        // Create certificates list for https binding
        let crtFileName = Path.join(this.proxyManager.engine.configurationsFolder, "list.crt");
        let crtList = this.def.wildcardDomains.map(this.createCertificateFileName.bind(this))

        let hasFrontEnds = false;

        if (this.def.rules) {
            for (const rule of this.def.rules) {
                hasFrontEnds = true;
                if (rule && rule.tlsDomain) {
                    let domainName = rule.tlsDomain;

                    try {
                        if (domainName) {
                            let fullName = this.createCertificateFileName(domainName);
                            if (crtList.indexOf(fullName) < 0) {
                                if (!dryrun) {
                                    // Ensures certificate exist
                                    await this.proxyManager.createCertificate(domainName, this.def.tlsEmail);
                                }
                                crtList.push(fullName);
                            }
                        }
                    }
                    catch (e) {
                        util.log("Certificate creation for domain " + domainName + " failed. " + e.message);
                    }
                }
            }
        }
        if (!dryrun) {
            fs.writeFileSync(crtFileName, crtList.join('\n'));
        }

        if (crtList.length > 0) {
            this.frontends.push(`  bind *:443 ssl crt-list ${crtFileName}`);
        }
        else {
            this.frontends.push(`  bind *:80`);
        }

        return hasFrontEnds;
    }
開發者ID:Zenasoft,項目名稱:vulcain-loadbalancer,代碼行數:55,代碼來源:template.ts

示例6: next

 router.use((req: Request, res: Response, next: any)=> {
   util.log(util.format("Request to: %s:%s -- Params:%s",
     req.url, req.method, JSON.stringify(req.body)));
   res.setHeader('Access-Control-Allow-Credentials', "true");
   res.header("Access-Control-Allow-Origin", req.header("Origin"));
   res.header("Access-Control-Allow-Methods", "GET,POST,PUT,HEAD,DELETE,OPTIONS");
   res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
   if ('OPTIONS' == req.method) {
     res.sendStatus(200);
   }
   else {
     next();
   }
 });
開發者ID:twicepixels,項目名稱:tp-main-api,代碼行數:14,代碼來源:app.router.ts

示例7: emitBackends

    private emitBackends(rule: RuleDefinition, aclIf: string, path: string, cx: number) {

        let serviceName = `${rule.serviceName.replace(/\./g, "-")}_${cx}`;
        let backend = "backend_" + serviceName;

        this.frontends.push("  use_backend " + backend + aclIf);

        this.backends.push("");
        this.backends.push("# " + rule.serviceName);
        this.backends.push("backend " + backend);

        this.backends.push("  option forwardfor");
        this.backends.push("  http-request set-header X-Forwarded-Port %[dst_port]");
        this.backends.push("  http-request add-header X-Forwarded-Proto https if { ssl_fc }");
        this.backends.push("  mode http");

        // Path rewriting
        if (rule.pathRewrite && path) {
            this.backends.push(`  http-request add-header x-vulcain-publicpath ${rule.path}`);
            let rw = rule.pathRewrite;
            let parts = rw.split(':');
            if (parts.length === 1) {
                // Replace path by pathRewrite
                this.backends.push("  reqrep ^([^\\ :]*)\\ " + path + "  \\1\\ " + rw + "\\2");
            } else if (parts.length === 2) {
                this.backends.push("  reqrep ^([^\\ :]*)\\ " + this.normalizeRegex(parts[0]) + "  \\1\\ " + this.normalizeRegex(parts[1]));
            }
            else {
                util.log(`Malformed rewriting path ${rw} is ignored for rule ${rule.id}`);
            }
        }

        if (rule.backendConfig) {
            let parts = rule.backendConfig.split(';').map(p => p && p.trim());
            parts.forEach(p => {
                if (p) {
                    this.backends.push(p);
                }
            });
        }
        this.backends.push("  server " + serviceName + " " + rule.serviceName + ":" + (rule.servicePort || "8080"));
    }
開發者ID:Zenasoft,項目名稱:vulcain-loadbalancer,代碼行數:42,代碼來源:template.ts

示例8:

import * as util from "util";

util.log('Here is our TypeScript starter project for Node.js');
開發者ID:ChezCrawford,項目名稱:ts-node-starter,代碼行數:3,代碼來源:app.ts

示例9: log

 compiler['plugin']('invalid', () => {
   log('==== Change detected. Compiling... =====');
   startTime = new Date().getTime();
 });
開發者ID:botique-ai,項目名稱:bigg-botique,代碼行數:4,代碼來源:bundleTypescriptAndWatch.ts

示例10: require

import { Server } from './server';
import { EngineFactory } from './host';
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
//    Copyright (c) Zenasoft
//
const util = require('util');

// -------------------------------------------------------------------
// START
// -------------------------------------------------------------------
util.log("Vulcain load balancer - version 2.0.0");

process.on('unhandledRejection', function (reason, p) {
    console.log("Unhandled rejection at: Promise ", p, " reason: ", reason);
});

const engine = EngineFactory.createEngine();
const server = new Server(engine);
server.start();
開發者ID:Zenasoft,項目名稱:vulcain-loadbalancer,代碼行數:30,代碼來源:index.ts


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