mirror of
https://git.hibas.dev/OpenServer/NodeLogging.git
synced 2025-07-01 12:41:11 +00:00
Adding events and fixing call stack in one line problem
This commit is contained in:
3
out/index.d.ts
vendored
3
out/index.d.ts
vendored
@ -1,3 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from "events";
|
||||
export declare class Logging {
|
||||
private static logFileLocation;
|
||||
private static stdout;
|
||||
@ -5,6 +7,7 @@ export declare class Logging {
|
||||
private static errorStream;
|
||||
private static writing;
|
||||
private static queue;
|
||||
static events: EventEmitter;
|
||||
static config(logfolder: string, stdout: boolean): void;
|
||||
static debug(...message: any[]): void;
|
||||
static log(...message: any[]): void;
|
||||
|
@ -2,6 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util = require("util");
|
||||
const fs = require("fs");
|
||||
const events_1 = require("events");
|
||||
const Reset = "\x1b[0m";
|
||||
const Bright = "\x1b[1m";
|
||||
const Dim = "\x1b[2m";
|
||||
@ -44,7 +45,11 @@ class Logging {
|
||||
Logging.errorMessage(error);
|
||||
return;
|
||||
}
|
||||
var message = error.name + " " + error.message + "\n" + error.stack;
|
||||
let m = "";
|
||||
error.stack.forEach(e => {
|
||||
m += e.toString() + "\n";
|
||||
});
|
||||
var message = error.name + " " + error.message + "\n" + m;
|
||||
Logging.message(LoggingTypes.Error, [message]);
|
||||
}
|
||||
static errorMessage(...message) {
|
||||
@ -89,6 +94,7 @@ class Logging {
|
||||
}
|
||||
Logging.writeMessageToFile(m, type === LoggingTypes.Error);
|
||||
}
|
||||
Logging.events.emit("message", { type: type, message: mb });
|
||||
if (this.stdout)
|
||||
console.log(consoleLogFormat + m + Reset);
|
||||
}
|
||||
@ -155,6 +161,7 @@ Logging.logFileLocation = "./logs/";
|
||||
Logging.stdout = true;
|
||||
Logging.writing = false;
|
||||
Logging.queue = new Array();
|
||||
Logging.events = new events_1.EventEmitter();
|
||||
exports.Logging = Logging;
|
||||
function _getCallerFile() {
|
||||
try {
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user