本文整理汇总了TypeScript中colors.setTheme函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setTheme函数的具体用法?TypeScript setTheme怎么用?TypeScript setTheme使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setTheme函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
export function init(configuration: Configuration): void {
(colors as any).enabled = configuration.colors.enabled;
colors.setTheme({
failed: configuration.colors.failed,
pending: configuration.colors.pending,
successful: configuration.colors.successful,
});
}
示例2: require
var colors = require('colors');
colors.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'cyan',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red',
h1: 'grey',
h2: 'yellow'
});
export class Log {
/**
* Console log heading 1.
*
* @param {string|object} message
* @return {void}
*/
static title(message: any): void {
console.log(colors.bold(message));
}
/**
* Console log heaing 2.
*
示例3: getDateTime
desc: '拷贝',
level: LogLevel.INFO
},
'DEBUG': {
color: 'red',
desc: '调试',
level: LogLevel.DEBUG
},
'TRACE': {
color: 'red',
desc: '跟踪',
level: LogLevel.TRACE
}
}
colors.setTheme(LogType)
function getDateTime (date = new Date(), format = 'HH:mm:ss') {
let fn = (d: number) => {
return ('0' + d).slice(-2)
}
if (date && _.isString(date)) {
date = new Date(Date.parse(date))
}
const formats = {
YYYY: date.getFullYear(),
MM: fn(date.getMonth() + 1),
DD: fn(date.getDate()),
HH: fn(date.getHours()),
mm: fn(date.getMinutes()),
ss: fn(date.getSeconds())
示例4: info
interface ILog {
namespace: string
info(title: string, desc: string): void
warn(title: string, desc: string): void
error(title: string, desc: string): void
}
const env = process.env.NODE_ENV || 'production'
const isPro = env !== 'development'
if (env === 'development') {
// const colors = import('colors')
const colors = require('colors')
colors.setTheme({
info: 'green',
warn: 'yellow',
error: 'red',
bold: 'bold',
})
}
export const accessLogger = log4js.getLogger('access')
export const infoLogger = log4js.getLogger('info')
export const errorLogger = log4js.getLogger('error')
export const warnLogger = log4js.getLogger('warn')
/**
* log4js 实例
*/
export const Log4js = log4js