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


TypeScript format.splat方法代码示例

本文整理汇总了TypeScript中winston.format.splat方法的典型用法代码示例。如果您正苦于以下问题:TypeScript format.splat方法的具体用法?TypeScript format.splat怎么用?TypeScript format.splat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在winston.format的用法示例。


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

示例1: constructor

    constructor(browser: string, headlessMode: boolean = false, logger?: winston.Logger) {

        if(logger){
            this.logger =logger;
        }else {
            this.logger = winston.loggers.get('tasteeLog');
            this.logger.configure({
                level: 'info',
                format: winston.format.combine(
                    winston.format.colorize(),
                    winston.format.splat(),
                    winston.format.simple()
                  ),
                transports: [
                    new winston.transports.Console()
                ]
              });
        }

        if (browser) {
            let webdriver = require('selenium-webdriver');
            switch (browser) {
                case 'chrome':
                    if (headlessMode) {
                        var chrome = require('selenium-webdriver/chrome');
                        this.driver = new webdriver.Builder()
                            .withCapabilities(selenium.Capabilities.chrome())
                            .setChromeOptions(new chrome.Options().headless())
                            .build();
                    }
                    else {
                        this.driver = new webdriver.Builder()
                            .forBrowser('chrome')
                            .build();
                    }
                    break;
                case 'firefox':
                    if (headlessMode) {
                        var firefox = require('selenium-webdriver/firefox');
                        this.driver = new webdriver.Builder()
                            .withCapabilities(selenium.Capabilities.firefox())
                            .setFirefoxOptions(new firefox.Options().headless())
                            .build();
                    }
                    else {
                        this.driver = new webdriver.Builder()
                            .forBrowser('firefox')
                            .build();
                    }
                    break;
                default:
                    this.driver = new webdriver.Builder()
                        .forBrowser('phantomjs')
                        .build();
                    break;
            }
        }
        this.reporter = new TasteeReporter();
    }
开发者ID:tastee,项目名称:tastee-core,代码行数:59,代码来源:tastee-engine.ts

示例2: createLogger

import { Logger as WLogger } from 'winston';
import { StreamOptions } from 'morgan';
import { createLogger, transports, format } from 'winston';

export namespace Log {
  export let log: WLogger = createLogger({
    transports: [
      new transports.File({
        level: 'error',
        filename: './log/errors.log',
        handleExceptions: true,
        maxsize: (1 * 1024 * 1024), // 1MB
        maxFiles: 5,
        format: format.combine(
          format.splat(),
          format.timestamp(),
          format.json()
        )
      }),
      new transports.File({
        level: 'info',
        filename: './log/all-logs.log',
        handleExceptions: false,
        maxsize: (1 * 1024 * 1024), // 1MB
        maxFiles: 5,
        format: format.combine(
          format.splat(),
          format.timestamp(),
          format.json()
        )
      }),
开发者ID:OysteinAmundsen,项目名称:gymsystems,代码行数:31,代码来源:log.ts

示例3:

  }

  if (process.env.NODE_ENV === 'development' || !fileLogger) {
    yield new winston.transports.Console({
      format: formatter,
    })
  }
}

const textFormat = winston.format.printf((info) => {
  return `${info.timestamp} [${info.level.padStart(5, ' ')}]: ${info.message}`
})

// prettier-ignore
const formatter = winston.format.combine(
    winston.format.timestamp(),
    winston.format.splat(),
    winston.format.simple(),
    textFormat
)

const isFileLoggerAvailable = () => {
  return magic8bot.loggerFile && magic8bot.loggerFile.length > 0
}

export const logger = winston.createLogger({
  level: magic8bot.loggerLevel,
  format: formatter,
  transports: Array.from(getWinstonTransports()),
})
开发者ID:magic8bot,项目名称:magic8bot,代码行数:30,代码来源:logger.ts

示例4: describe

describe('Tastee Engine', function () {
    let engine: TasteeEngine;

    logger.configure({
        level: 'debug',
        format: winston.format.combine(
            winston.format.colorize(),
            winston.format.splat(),
            winston.format.simple()
          ),
        transports: [
            new winston.transports.Console()
        ]
      });

    beforeEach(function () {
        engine = new TasteeEngine(null);
        let driver = jasmine.createSpyObj("driver", ["quit"]);
        engine.driver = driver;
    });

    it(" propagates logger", function () {
        const infoLog = winston.loggers.get('infoLog');
        infoLog.configure({
            level: 'info'
          });

        let engineInfo = new TasteeEngine(null, false, infoLog);
        expect(engineInfo.logger).toBe(infoLog);
    });

    it(" quits selenium driver properly", function () {
        engine.stop();
        expect(engine.driver.quit).toHaveBeenCalled();
    });

    it(" execute simple js code", (done) => {
        let instruction = new Instruction(1, 'a line', '1+1');

        let promise = engine.execute([instruction]);
        promise.then(result => {
            expect(result.length).toBe(1);
            expect(result[0].valid).toBe(true);
            done();
        });
    });

    it(" execute empty codeLines", (done) => {
        let instruction = new Instruction(1, 'a line', '');

        engine.execute([instruction]).then(result => {
            expect(result.length).toBe(1);
            expect(result[0].valid).toBe(true);
            done();
        });
    });

    it(" execute unknown instruction", (done) => {
        let instruction = new Instruction(1, 'a line', 'bad code line');

        engine.execute([instruction]).then(result => {
            expect(result.length).toBe(1);
            expect(result[0].valid).toBe(false);
            done();
        });
    });

    it(" execute promise error", (done) => {
        let instruction = new Instruction(1, 'a line', 'throw new Error("exception!");');

        engine.execute([instruction]).then(result => {
            expect(result.length).toBe(1);
            expect(result[0].valid).toBe(false);
            done();
        });
    });
});
开发者ID:tastee,项目名称:tastee-core,代码行数:77,代码来源:tastee-engine.spec.ts


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