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


TypeScript chalk.blueBright函数代码示例

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


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

示例1: colorMessage

	private colorMessage(message: string, prefixColor: any, messageColor?: any): string {
		if (hasAnsi(message)) {
			return config.vpdb.logging.console.colored ? message : stripAnsi(message);
		}
		if (!config.vpdb.logging.console.colored) {
			return message;
		}
		const match = message.match(/^(\[[^\]]+])(.+)/);
		if (match) {
			let prefix: string;
			if (prefixColor == null) {
				const m = match[1].split('.');
				prefix = m.length === 2 ?
					'[' + chalk.cyan(m[0].substring(1)) + '.' + chalk.blueBright(m[1].substring(0, m[1].length - 1)) + ']' :
					'[' + chalk.cyan(match[1].substring(1, match[1].length - 1)) + ']';
			} else {
				prefix = prefixColor(match[1]);
			}
			return prefix + (messageColor ? messageColor(match[2]) : match[2]);
		}
		return messageColor ? messageColor(message) : message;
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:22,代码来源:logger.ts

示例2:

export const promptStr = (str: string) => {
  return chalk.blueBright(str);
};
开发者ID:the1mills,项目名称:clone-all-org-repos,代码行数:3,代码来源:utils.ts

示例3: assert

  );
  const oneLevelPathNodes = node.childNodes.filter(
    ({ nodeName, childNodes }) =>
      nodeName !== 'style' && childNodes.length === 0
  );
  assert(oneLevelPathNodes.length >= 1, debugName);

  return normalizeNode(node, debugName);
}

export const log = {
  info(message: string) {
    return console.log(chalk.green(`🌟 [Generate] ${message}`));
  },
  notice(message: string) {
    return console.log(chalk.blueBright(`🌟 [Notice] ${message}`));
  }
};

export function getIdentifier(identifier: string, theme: ThemeType) {
  switch (theme) {
    case 'fill':
      return `${identifier}Fill`;
    case 'outline':
      return `${identifier}Outline`;
    case 'twotone':
      return `${identifier}TwoTone`;
    default:
      throw new TypeError(
        `Unknown theme type: ${theme}, identifier: ${identifier}`
      );
开发者ID:ant-design,项目名称:ant-design-icons,代码行数:31,代码来源:index.ts

示例4: formatHeader

function formatHeader(group: string = '<group>', command: string = '[<command>]') {
	return `${chalk.blueBright(dojoArt)}
${chalk.bold('Usage:')}

  $ ${chalk.greenBright('dojo')} ${chalk.greenBright(group)} ${chalk.green(command)} [<options>] [--help]`;
}
开发者ID:dojo,项目名称:cli,代码行数:6,代码来源:help.ts

示例5: log

function log(ctx: Context, start: number, len: number, err: any = null, event: string = null) {

	const statusCode = err
		? (err.statusCode || err.status || 500)
		: (ctx.status || 404);
	let length: string;
	if ([204, 205, 304].includes(statusCode)) {
		length = '';
	} else if (len == null) {
		length = '-';
	} else {
		length = bytes(len).toLowerCase();
	}
	let cache: string = '';
	if (ctx.response.headers['x-cache-api']) {
		cache = ' [' + ctx.response.headers['x-cache-api'].toLowerCase() + ']';
	}

	const ip = ctx.request.get('x-forwarded-for') || ctx.ip || '0.0.0.0';
	const user = ctx.state.user ? ctx.state.user.name || ctx.state.user.username : '';
	let logUserIp: string;
	if (user) {
		logUserIp = chalk.cyan(user) + ':' + chalk.blueBright(ip);
	} else {
		logUserIp = chalk.blueBright(ip);
	}

	const upstream = err ? chalk.redBright('*ERR* ') : event === 'close' ? chalk.yellowBright('*CLOSED* ') : '';

	const logStatus = statusStyle[Math.floor(statusCode / 100) * 100] || statusStyle[100];
	const logMethod = methodStyle[ctx.method] || methodStyle.GET;
	const duration = Date.now() - start;
	ctx.state.request.duration = duration;
	ctx.state.request.size = len;

	// log this
	const message = `[${logUserIp}] ${upstream}${logStatus(' ' + statusCode + ' ')} ${logMethod(ctx.method + ' ' + ctx.originalUrl)} ${duration}ms - ${length}${cache}`;
	const level = statusCode >= 500 ? 'error' : 'info';
	const fullLog = statusCode >= 400 && statusCode !== 404;
	const requestHeaders = stripAuthHeaders(ctx.request.headers);
	logger.text(ctx.state, level, message);
	logger.json(ctx.state, level, {
		type: 'access',
		message: `${ctx.method} ${ctx.originalUrl} [${ctx.response.status}]`,
		level,
		request: {
			id: ctx.state.request.id,
			ip: ctx.state.request.ip,
			method: ctx.request.method,
			path: ctx.request.url,
			headers: fullLog ? Object.keys(requestHeaders)
				.filter(header => !['accept', 'connection', 'pragma', 'cache-control', 'host', 'origin'].includes(header))
				.reduce((obj: { [key: string]: string }, key: string) => { obj[key] = requestHeaders[key]; return obj; }, {}) : undefined,
			body: ctx.request.get('content-type').startsWith('application/json') ? ctx.request.rawBody : undefined,
		},
		response: {
			status: ctx.response.status,
			body: fullLog && ctx.response.get('content-type').startsWith('application/json') ? (isObject(ctx.response.body) ? JSON.stringify(ctx.response.body) : ctx.response.body) : undefined,
			headers: fullLog ? Object.keys(ctx.response.headers)
				.filter(header => !['x-request-id', 'x-user-id', 'x-user-dirty', 'x-cache-api', 'x-response-time', 'x-token-refresh', 'vary', 'access-control-allow-origin', 'access-control-allow-credentials', 'access-control-expose-headers'].includes(header))
				.reduce((obj: { [key: string]: string }, key: string) => { obj[key] = ctx.response.headers[key]; return obj; }, {}) : undefined,
			duration: ctx.state.request.duration,
			size: ctx.state.request.size,
			cached: ctx.response.headers['x-cache-api'] ? ctx.response.headers['x-cache-api'] === 'HIT' : undefined,
		},
	});
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:67,代码来源:logger.middleware.ts


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