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


TypeScript bunyan.createLogger函数代码示例

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

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

示例1: constructor

 constructor(loggerOpts: LoggerOpts ) {
   super()
   const {name, devMode} = loggerOpts
   if (devMode) {
     let streams = buildDevOpts(loggerOpts.level)
     let opts: LoggerOptions = {name}
     if (streams) {
       opts.streams = streams
     }
     this.logger = createLogger(opts)
   } else {
     this.logger = createLogger({name})
   }
 }
开发者ID:instructure,项目名称:ftl-engine,代码行数:14,代码来源:Logger.ts


示例2: start

export function start(logger?:Logger):Promise<any> {
    logger = logger || createLogger({
            name: "express-typescript-sequelize",
            stream: process.stdout,
            level: "info"
        });
    let storageManager = new SequelizeStorageManager({database: "example", username: process.env.EXAMPLE_USERNAME || "username", password: ""}, logger);

    return storageManager.init()
        .then(() => {
            return configureExpress(logger, storageManager)
                .then((app:express.Application) => {
                    return congifureRoutes(app, logger, storageManager)
                        .then(() => {
                            return app;
                        });
                })
                .then((app:express.Application) => {
                    return new Promise((resolve) => {
                        var server = app.listen(3000, () => {
                            resolve(server);
                        });
                    });
                })
        });
}
开发者ID:JesseDavid,项目名称:express-typescript-sequelize,代码行数:26,代码来源:index.ts


示例3: runAsyncTest

  public static async runAsyncTest(): Promise<void> {
    let logger: bunyan.Logger = bunyan.createLogger({
      level: "trace",
      name: "cloco-node-client (test)",
    });

    let options: IOptions = {
      encryptor: new AesEncryptor("This_is_an_encryption_passphrase"),
      log: logger,
      ttl: 60,
    };

    // initialize the client and load in the configuration.
    let client: ClocoClient = new ClocoClient(options);
    await client.init();
    logger.info("cloco client initialized");

    // check the state of the current cache.
    logger.info(Cache.current);
    logger.info(client.get<any>("default"));

    // write to the cache.
    let updated: any = {foo: "bar", updated: new Date()};
    await client.put<any>("default", updated);
    await client.put<any>("a-third-cob", "some updated text " + new Date().toString());
    await client.put<any>("another-cob", "some encrypted text " + new Date().toString());

    // check the state of the current cache.
    logger.info(Cache.current);
    AsyncTest.timer = setTimeout(() => AsyncTest.keepAlive(), 1000);
  }
开发者ID:cloudconfig,项目名称:cloco-node,代码行数:31,代码来源:test-script.ts


示例4: log

export function log(): bunyan.Logger {
  if ( !_log ) {
    _log = bunyan.createLogger( { name: 'no app'} );
    _log.level(bunyan.WARN);
  }
  return _log;
}
开发者ID:micurs,项目名称:relaxjs,代码行数:7,代码来源:internals.ts


示例5:

logger.init = (config) => { /**  init method to initiate the creation of logger */
  logger.root = bunyan.createLogger(
    {
      name: 'root',
      serializers: { /**  serializer converts App Objects passed to it to  readable json format eg :
                           logger.info(object, 'This is a log ref for object');
                        */
        err: bunyan.stdSerializers.err,
        req: bunyan.stdSerializers.req,
        res: bunyan.stdSerializers.res
      },
      streams: [
        {
          level: config.systemConfig.log.level,
          stream: process.stdout   //type is defaulted to 'stream'
        },
        {
          level: config.systemConfig.log.level,  // this is the level of error logs
          path: config.systemConfig.log.path,  //path of log file where logs are going to be written to
          // type is defaulted to 'file'
          type: 'rotating-file',  //this is responsible for creating back copies of log files overwriting default
          period: '1d',  //this is the period of rotation for creating back copies
          count: 3,  //this is the number of back copies to be made
        }
      ],
      src: true
    }
  );
}
开发者ID:girishgupta211,项目名称:LAAS_Server,代码行数:29,代码来源:logger.ts


示例6: it

    it("when logger passed in options this should be used to init the logger.", function(): void {

      let options: any = {};
      options.log = bunyan.createLogger({
              name: "unit-test",
          });

      Logger.init(options);
      expect(Logger.log).toEqual(options.log);
    });
开发者ID:cloudconfig,项目名称:cloco-node,代码行数:10,代码来源:logger.spec.ts


示例7: init

  /**
   * Initializes the static logger.
   * @param {IOptions} options The initialization options.
   */
  public static init(options: IOptions): void {
    if (options.log) {
      Logger.log = options.log;
    } else {
      Logger.log = bunyan.createLogger({
            name: "cloco-node-client",
        });
    }

    Logger.log.debug("Logging is initialized.");
  }
开发者ID:cloudconfig,项目名称:cloco-node,代码行数:15,代码来源:logger.ts


示例8: bunyanLogger

export function bunyanLogger(): Bunyan {
  // add the global bunyan logger to std out
  const streams = [];
  streams.push({
    stream: process.stdout,
  });

  return Bunyan.createLogger({
    streams,
    name: 'EliakarisBlog',
  });
}
开发者ID:eliakaris,项目名称:blog,代码行数:12,代码来源:logger.ts


示例9: constructor

 constructor(cfg?: any) {
     cfg = cfg || {};
     console.log("Configuring logger with platform stream", cfg);
     this.platformStream = new PlatformStream(cfg);
     this.root = bunyan.createLogger({
         name: 'system',
         streams: [{
             type: 'stream',
             level: cfg.level || 'info',
             stream: this.platformStream
         }]
     });
 }
开发者ID:Covistra,项目名称:cmbf2,代码行数:13,代码来源:central-logger.ts


示例10: constructor

  constructor() {
    this.caches = {
      DEP_CACHE,
      COMPILER_CACHE,
      DEPLOY_DIR
    };
    this.logger = createLogger(LOGGER);
    this.GAPI_KEY = process.env.GAPI_KEY;
    this.scriptCompilerArgs = {};
    this.styleCompilerArgs = {};
    this.htmlCompilerArgs = { filters: FILTERS };

    // Set up templates
    this.templates = {};
    const tempReg = new RegExp("(.*)\.template\..*");
    const temps = glob.sync("*.template.*", { cwd: join(__dirname, "templates")});
    temps.forEach(t => {
      const m = t.match(tempReg);
      if (!m) return;
      const [_, name] = m;
      const p = join(__dirname, "templates", t);
      try {
        const templater = require(p).default;
        this.templates[name] = new templater();
      } catch (e) {
        console.log(`There was an error loading ${p}. Until it is fixed, template ${name} will not be available for use.`);
        console.log(e);
      }
    });

    // Set up fetchers
    this.fetchers = {};
    const fetchReg = new RegExp("(.*)\.fetcher\..*");
    const fetchs = glob.sync("*.fetcher.*", { cwd: join(__dirname, "fetchers")});
    fetchs.forEach(f => {
      const m = f.match(fetchReg);
      if (!m) return;
      const [_, name] = m;
      const p = join(__dirname, "fetchers", f);
      try {
        const fetcher = require(p).default;
        this.fetchers[name] = new fetcher(fetcherArgs[name]);
      } catch (e) {
        console.log(`There was an error loading ${p}. Until it is fixed, fetcher ${name} will not be available for use.`);
        console.log(e);
      }
    });
  }
开发者ID:tbtimes,项目名称:lede-cli,代码行数:48,代码来源:cli.config.ts



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