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


TypeScript format.combine方法代码示例

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


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

示例1: getConfig

export function getConfig() {

  const configPath = process.env.CONFIG_PATH || process.argv[2] || './config.json'
  let config: Config
  try {
    config = Object.assign(
      {}, configDefaults, JSON.parse(fs.readFileSync(configPath).toString()))
  } catch (e) {
    console.error(`Error reading config "${configPath}": ${e}`)
    config = Object.assign({}, configDefaults)
  }

  const formats = [
    config.argsTransport.colorize ? winston.format.colorize() : null,
    config.argsTransport.timestamp ?
      winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }) : null,
    config.argsTransport.json ? winston.format.json() : winston.format.simple()
  ].filter(f => f !== null)
  const format = formats.length ? winston.format.combine(...formats) : null

  logger.configure({
    format: format, 
    transports: [new winston.transports.Console(config.argsTransport)]
  })

  return config
}
开发者ID:blockstack,项目名称:blockstack-registrar,代码行数:27,代码来源:config.ts

示例2: getConfig

export function getConfig() {
  const configPath = process.env.CONFIG_PATH || process.argv[2] || './config.json'
  let config: Config
  try {
    config = { ...configDefaults, ...JSON.parse(fs.readFileSync(configPath).toString()) }
  } catch (e) {
    console.error(`Failed to read config: ${e}`)
    config = { ...configDefaults }
  }

  if (process.env['GAIA_DISK_STORAGE_ROOT_DIR']) {
    config.diskSettings.storageRootDirectory = process.env['GAIA_DISK_STORAGE_ROOT_DIR']
  }

  const formats = [
    config.argsTransport.colorize ? winston.format.colorize() : null,
    config.argsTransport.timestamp ?
      winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }) : null,
    config.argsTransport.json ? winston.format.json() : winston.format.simple()
  ].filter(f => f !== null)
  const format = formats.length ? winston.format.combine(...formats) : null

  logger.configure({
    format: format,
    transports: [new winston.transports.Console(config.argsTransport)]
  })

  return config
}
开发者ID:blockstack,项目名称:blockstack-registrar,代码行数:29,代码来源:config.ts

示例3: 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

示例4: constructor

	constructor() {
		const alignedWithColorsAndTime = winston.format.combine(
			winston.format.colorize(),
			winston.format.timestamp(),
			//winston.format.align(),
			winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`),
		);

		this.textLogger = winston.createLogger({
			format: alignedWithColorsAndTime,
			transports: [],
			level: config.vpdb.logging.level,
		});

		if (config.vpdb.logging.console.enabled) {
			this.textLogger.add(new winston.transports.Console());
		}
		/* istanbul ignore next */
		if (config.vpdb.logging.file.text) {
			const logPath = resolve(config.vpdb.logging.file.text);
			const transport = new DailyRotateFile({
				filename: basename(logPath),
				dirname: dirname(logPath),
				zippedArchive: true,
				datePattern: 'YYYY-MM',
			});
			transport.on('rotate', (oldFilename, newFilename) => {
				this.info(null, '[app] Rotating text logs from %s to %s.', oldFilename, newFilename);
			});
			transport.on('new', newFilename => {
				this.info(null, '[app] Creating new text log at %s.', newFilename);
			});
			this.textLogger.add(transport);
			this.info(null, '[app] Text logger enabled at %s.', logPath);
		}
		/* istanbul ignore next */
		if (config.vpdb.logging.file.json) {
			const logPath = resolve(config.vpdb.logging.file.json);
			const transport = new DailyRotateFile({
				filename: basename(logPath),
				dirname: dirname(logPath),
				zippedArchive: true,
				datePattern: 'YYYY-MM',
			});
			transport.on('rotate', (oldFilename, newFilename) => {
				this.info(null, '[app] Rotating JSON logs from %s to %s.', oldFilename, newFilename);
			});
			transport.on('new', newFilename => {
				this.info(null, '[app] Creating new JSON log at %s.', newFilename);
			});
			this.jsonLogger = winston.createLogger({
				format: winston.format.json(),
				transports: [transport],
				level: config.vpdb.logging.level,
			});
			this.info(null, '[app] JSON logger enabled at %s.', logPath);
		}
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:58,代码来源:logger.ts

示例5: setVerbosity

 setVerbosity (v: LoggerOptions["level"]) {
     this.logger.configure({
         level: v,
         transports: [new winston.transports.Console()],
         format: winston.format.combine(
             winston.format.colorize({ all: true }),
             logFmt
         )
     })
 }
开发者ID:0mkara,项目名称:remix,代码行数:10,代码来源:logger.ts

示例6: constructor

 constructor () {
     this.logger = winston.createLogger({
         level: 'error',
         transports: [new winston.transports.Console()],
         format: winston.format.combine(
             winston.format.colorize({ all: true }),
             logFmt
         )
     })
 }
开发者ID:0mkara,项目名称:remix,代码行数:10,代码来源:logger.ts

示例7: constructor

  /**
   * Constructs a new instance of PolymerLogger. This creates a new internal
   * `winston` logger, which is what we use to handle most of our logging logic.
   *
   * Should generally called with getLogger() instead of calling directly.
   */
  constructor(options: Options) {
    options = Object.assign({colorize: true}, options);

    const formats = [];
    if (options.colorize) {
      formats.push(winston.format.colorize());
    }
    formats.push(winston.format.align());
    formats.push(plylogPrettify({ colorize: options.colorize }));
    this._transport = defaultConfig.transportFactory({
      level: options.level || 'info',
      format: winston.format.combine(...formats),
    });

    this._logger = winston.createLogger({transports: [this._transport]});

    this.error = this._log.bind(this, 'error');
    this.warn = this._log.bind(this, 'warn');
    this.info = this._log.bind(this, 'info');
    this.debug = this._log.bind(this, 'debug');
  }
开发者ID:Polymer,项目名称:plylog,代码行数:27,代码来源:index.ts

示例8:

import * as winston from 'winston';

export const Logger: winston.Logger =
  winston.createLogger({
                         transports:  [
                           new winston.transports.File({
                                                         filename: 'logs/error.log',
                                                         level:    'error',
                                                         maxFiles: 5,
                                                         maxsize:  10485760,
                                                         format:   winston.format.json(),
                                                       }),
                           new winston.transports.File({
                                                         filename: 'logs/all.log',
                                                         maxFiles: 5,
                                                         maxsize:  10485760,
                                                         format:   winston.format.json(),
                                                       }),
                           new winston.transports.Console({
                                                            level:            'debug',
                                                            handleExceptions: true,
                                                            format:           winston.format.combine(
                                                              winston.format.colorize(),
                                                              winston.format.simple(),
                                                            ),
                                                          }),
                         ],
                         exitOnError: false,
                       });
开发者ID:trungx,项目名称:vue-starter,代码行数:29,代码来源:Logger.ts

示例9:

  }

  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

示例10: 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


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