當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。