@anjianshi/utils 1.2.1 → 1.2.3

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.
@@ -1,4 +1,4 @@
1
- import chalk from 'chalk';
1
+ import * as chalk from 'chalk';
2
2
  import { type Logger, type LogInfo, LogHandler } from '../logging/index.js';
3
3
  export * from '../logging/index.js';
4
4
  /**
@@ -5,7 +5,7 @@
5
5
  import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
- import chalk from 'chalk';
8
+ import * as chalk from 'chalk';
9
9
  import dayjs from 'dayjs';
10
10
  import { logger as defaultLogger, LogLevel, LogHandler, formatters, } from '../logging/index.js';
11
11
  export * from '../logging/index.js';
package/logging/index.js CHANGED
@@ -34,6 +34,7 @@ export class Logger {
34
34
  }
35
35
  static getRealLevel(raw) {
36
36
  if (typeof raw === 'string') {
37
+ raw = raw.toLocaleLowerCase();
37
38
  if (logLevelMap[raw] === undefined)
38
39
  throw new Error('Not supported log level: ' + raw);
39
40
  return logLevelMap[raw];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-utils",
6
6
  "bugs": {
@@ -5,7 +5,7 @@
5
5
  import fs from 'node:fs'
6
6
  import path from 'node:path'
7
7
  import { fileURLToPath } from 'node:url'
8
- import chalk from 'chalk'
8
+ import * as chalk from 'chalk'
9
9
  import dayjs from 'dayjs'
10
10
  import {
11
11
  logger as defaultLogger,
@@ -128,7 +128,7 @@ export class FileHandler extends LogHandler {
128
128
  totalLength += itemString.length
129
129
  } else {
130
130
  itemStrings.push(
131
- itemString.slice(0, this.options.maxLength - totalLength) + ' [too long, sliced]',
131
+ itemString.slice(0, this.options.maxLength - totalLength) + ' [too long, sliced]'
132
132
  )
133
133
  break
134
134
  }
@@ -179,7 +179,7 @@ export class FileHandler extends LogHandler {
179
179
  const { dir, filePrefix } = this.options
180
180
  return path.join(
181
181
  dir,
182
- `${filePrefix ? `${filePrefix}-` : ''}${dayjs().format('YYYY-MM-DD')}.log`,
182
+ `${filePrefix ? `${filePrefix}-` : ''}${dayjs().format('YYYY-MM-DD')}.log`
183
183
  )
184
184
  }
185
185
 
@@ -44,6 +44,7 @@ export class Logger {
44
44
 
45
45
  static getRealLevel(raw: LogLevel | string) {
46
46
  if (typeof raw === 'string') {
47
+ raw = raw.toLocaleLowerCase()
47
48
  if (logLevelMap[raw] === undefined) throw new Error('Not supported log level: ' + raw)
48
49
  return logLevelMap[raw]!
49
50
  }