mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: send: 区分远端错误与本地错误
This commit is contained in:
1 parent
6f96e7fa9e
commit
f2fbbb8af9
4 files changed
+29
-10
No files matched your search
@@ -3,7 +3,7 @@ import { argv } from 'yargs';
|
||||
import { Time } from './utils';
|
||||
|
||||
const instances: Record<string, Logger> = {};
|
||||
type LogFunction = (format: any, ...param: any[]) => void;
|
||||
type LogFunction = (format: any, ...param: any[]) => boolean;
|
||||
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug';
|
||||
export interface Logger extends Record<LogType, LogFunction> { }
|
||||
export class Logger {
|
||||
@@ -37,10 +37,11 @@ export class Logger {
|
||||
|
||||
private createMethod(name: LogType, prefix: string, minLevel: number) {
|
||||
this[name] = (...args: [any, ...any[]]) => {
|
||||
if (this.level < minLevel) return;
|
||||
if (this.level < minLevel) return false;
|
||||
const msg = `${prefix} ${this.name} ${this.format(...args)}`;
|
||||
if (process.send) process.send({ event: 'message/log', payload: [msg] });
|
||||
else global.Hydro.service.bus.parallel('message/log', msg);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user