@shuvi/utils 1.0.0-rc.17 → 1.0.0-rc.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/logger.d.ts CHANGED
@@ -4,4 +4,17 @@ export interface Logger {
4
4
  warn(...args: any[]): void;
5
5
  error(...args: any[]): void;
6
6
  }
7
- export default function logger(namespace: string): Logger;
7
+ export declare const colorize: {
8
+ error: (...message: any[]) => string;
9
+ warn: (...message: any[]) => string;
10
+ };
11
+ declare class LoggerImpl implements Logger {
12
+ private _debug;
13
+ constructor(namespace: string);
14
+ debug(formatter: any, ...args: any[]): void;
15
+ info(...args: any[]): void;
16
+ warn(...args: any[]): void;
17
+ error(...args: any[]): void;
18
+ }
19
+ declare const _default: LoggerImpl;
20
+ export default _default;
package/lib/logger.js CHANGED
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.colorize = void 0;
6
7
  const debug_1 = __importDefault(require("debug"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ exports.colorize = {
10
+ error: (...message) => chalk_1.default.red(...message),
11
+ warn: (...message) => chalk_1.default.yellow(...message)
12
+ };
7
13
  class LoggerImpl {
8
14
  constructor(namespace) {
9
15
  this._debug = (0, debug_1.default)(namespace);
@@ -12,16 +18,13 @@ class LoggerImpl {
12
18
  this._debug(formatter, ...args);
13
19
  }
14
20
  info(...args) {
15
- console.log("INFO:", ...args);
21
+ console.log(...args);
16
22
  }
17
23
  warn(...args) {
18
- console.warn("WARN:", ...args);
24
+ console.warn(exports.colorize.warn(...args));
19
25
  }
20
26
  error(...args) {
21
- console.error("ERROR:", ...args);
27
+ console.error(exports.colorize.error(...args));
22
28
  }
23
29
  }
24
- function logger(namespace) {
25
- return new LoggerImpl(namespace);
26
- }
27
- exports.default = logger;
30
+ exports.default = new LoggerImpl('shuvi');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/utils",
3
- "version": "1.0.0-rc.17",
3
+ "version": "1.0.0-rc.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",