• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chalk.blueBright函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chalk.bold函数代码示例发布时间:2022-05-25
下一篇:
TypeScript chalk.blue函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap