1
0
mirror of https://git.stamm.me/OpenServer/NodeLogging.git synced 2024-11-22 06:09:24 +00:00

Fixing error, when passing empty error

This commit is contained in:
Fabian Stamm 2018-09-17 22:42:22 +02:00
parent 95c93f22d0
commit 976f3cc95c
6 changed files with 15 additions and 12 deletions

16
out/index.d.ts vendored
View File

@ -45,7 +45,7 @@ export declare class LoggingBase {
constructor(options?: Partial<LoggingBaseOptions>); constructor(options?: Partial<LoggingBaseOptions>);
console_out: boolean; console_out: boolean;
waitForSetup(): Promise<void>; waitForSetup(): Promise<void>;
private setup(); private setup;
events: EventEmitter; events: EventEmitter;
debug(...message: any[]): void; debug(...message: any[]): void;
log(...message: any[]): void; log(...message: any[]): void;
@ -53,12 +53,12 @@ export declare class LoggingBase {
logWithCustomColors(type: LoggingTypes, colors: string, ...message: any[]): void; logWithCustomColors(type: LoggingTypes, colors: string, ...message: any[]): void;
error(error: Error | string): void; error(error: Error | string): void;
errorMessage(...message: any[]): void; errorMessage(...message: any[]): void;
private message(type, message, customColors?, caller?); private message;
private writeMessageToFile(message, error?); private writeMessageToFile;
private checkQueue(); private checkQueue;
private writeToLogFile(data); private writeToLogFile;
private writeToErrorFile(data); private writeToErrorFile;
private initializeFile(file, new_file?); private initializeFile;
} }
export declare const Logging: LoggingBase; export declare const Logging: LoggingBase;
export default Logging; export default Logging;
@ -66,5 +66,5 @@ export declare enum LoggingTypes {
Log = 0, Log = 0,
Warning = 1, Warning = 1,
Error = 2, Error = 2,
Debug = 3, Debug = 3
} }

View File

@ -94,6 +94,8 @@ class LoggingBase {
this.message(type, message, colors); this.message(type, message, colors);
} }
error(error) { error(error) {
if (!error)
error = "Empty ERROR was passed, so no informations available";
if (typeof error === "string") { if (typeof error === "string") {
let e = new Error(); let e = new Error();
this.message(LoggingTypes.Error, [error, "\n", e.stack]); this.message(LoggingTypes.Error, [error, "\n", e.stack]);

File diff suppressed because one or more lines are too long

4
out/lock.d.ts vendored
View File

@ -7,6 +7,6 @@ export default class Lock {
private toCome; private toCome;
constructor(); constructor();
getLock(): Promise<Release>; getLock(): Promise<Release>;
private lock(); private lock;
private release(); private release;
} }

View File

@ -1 +1 @@
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../src/lock.ts"],"names":[],"mappings":";;AACA;IAOG;QANQ,YAAO,GAAY,KAAK,CAAC;QAIzB,WAAM,GAAmB,EAAE,CAAC;QAGjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAPD,IAAI,MAAM;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;aAC9C;YACF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;gBACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;oBACnB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACrC,CAAC,CAAC,CAAA;YACL,CAAC,CAAC,CAAA;SACJ;IACJ,CAAC;IAEO,IAAI;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,OAAO;QAClB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;SACxB;aAAM;YACJ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACvB;IACJ,CAAC;CACH;AAlCD,uBAkCC"} {"version":3,"file":"lock.js","sourceRoot":"","sources":["../src/lock.ts"],"names":[],"mappings":";;AACA,MAAqB,IAAI;IAOtB;QANQ,YAAO,GAAY,KAAK,CAAC;QAIzB,WAAM,GAAmB,EAAE,CAAC;QAGjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAPD,IAAI,MAAM;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;aAC9C;YACF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;gBACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;oBACnB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACrC,CAAC,CAAC,CAAA;YACL,CAAC,CAAC,CAAA;SACJ;IACJ,CAAC;IAEO,IAAI;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,OAAO;QAClB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;SACxB;aAAM;YACJ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACvB;IACJ,CAAC;CACH;AAlCD,uBAkCC"}

View File

@ -125,6 +125,7 @@ export class LoggingBase {
} }
error(error: Error | string) { error(error: Error | string) {
if (!error) error = "Empty ERROR was passed, so no informations available";
if (typeof error === "string") { if (typeof error === "string") {
let e = new Error() let e = new Error()
this.message(LoggingTypes.Error, [error, "\n", e.stack]); this.message(LoggingTypes.Error, [error, "\n", e.stack]);