# 使用level颜色

```javascript
const logFormat = winston.format.combine(
// 大写状态值
  winston.format(info => {
    info.level = info.level.toUpperCase()
    return info;
  })(),
  winston.format.colorize(),
  winston.format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZZ' }),
  winston.format.printf(({ level, message, timestamp }) => {
      return `${timestamp} ${level} ${message}`;
  })
);

const logger = createLogger({
  format: logFormat,
  transports: [
    new transports.Console({
      format: format.combine(format.colorize()),
    }),
  ],
});

const myLog = () => {
    winston.addColors({ error: 'bold underline red', info: 'bold underline green' });
    logger.log('info', 'test')
}
```

也可以在自己需要的字符中添加对应颜色

```javascript
\x1b[0;34m your word \x1b[0m

\033[0;34m your word \033[0m

```

对应颜色

```javascript
// foregroud     background
30                  40            // black
31                  41            // red
32                  42            // green
33                  43            // yellow
34                  44            // blue
35                  45            // magenta
36                  46            // cyan
37                  47            // white
```

```javascript
// background
40 // 
```
