mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
workspace: update eslint config
This commit is contained in:
1 parent
4e4f6688bc
commit
3a3983d38d
29 files changed
+169
-166
No files matched your search
@@ -3,22 +3,22 @@ import { argv } from 'yargs';
|
||||
import { Time } from './utils';
|
||||
|
||||
const instances: Record<string, Logger> = {};
|
||||
type LogFunction = (format: any, ...param: any[]) => void
|
||||
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug'
|
||||
type LogFunction = (format: any, ...param: any[]) => void;
|
||||
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug';
|
||||
export interface Logger extends Record<LogType, LogFunction> { }
|
||||
export class Logger {
|
||||
static readonly SUCCESS = 1
|
||||
static readonly ERROR = 1
|
||||
static readonly INFO = 2
|
||||
static readonly WARN = 2
|
||||
static readonly DEBUG = 3
|
||||
static baseLevel = argv.debug ? 3 : 2
|
||||
static showDiff = false
|
||||
static levels: Record<string, number> = {}
|
||||
static lastTime = 0
|
||||
static readonly SUCCESS = 1;
|
||||
static readonly ERROR = 1;
|
||||
static readonly INFO = 2;
|
||||
static readonly WARN = 2;
|
||||
static readonly DEBUG = 3;
|
||||
static baseLevel = argv.debug ? 3 : 2;
|
||||
static showDiff = false;
|
||||
static levels: Record<string, number> = {};
|
||||
static lastTime = 0;
|
||||
static formatters: Record<string, (this: Logger, value: any) => string> = {
|
||||
o: (value) => inspect(value).replace(/\s*\n\s*/g, ' '),
|
||||
}
|
||||
};
|
||||
|
||||
constructor(public name: string, private showDiff = false) {
|
||||
if (name in instances) return instances[name];
|
||||
@@ -48,7 +48,7 @@ export class Logger {
|
||||
return Logger.levels[this.name] ?? Logger.baseLevel;
|
||||
}
|
||||
|
||||
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff)
|
||||
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff);
|
||||
|
||||
format: (format: any, ...param: any[]) => string = (...args) => {
|
||||
if (args[0] instanceof Error) args[0] = args[0].stack || args[0].message;
|
||||
@@ -71,7 +71,7 @@ export class Logger {
|
||||
Logger.lastTime = now;
|
||||
}
|
||||
return format(...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
global.Hydro.Logger = Logger;
|
||||
|
||||
Reference in new issue
Block a user