1
0
mirror of https://git.hibas.dev/OpenServer/NodeLogging.git synced 2025-07-01 12:41:11 +00:00

platform independant filename extraction

This commit is contained in:
2017-10-21 12:45:20 +02:00
parent cec4cf158a
commit f8034d9758
4 changed files with 15 additions and 17 deletions

View File

@ -1,6 +1,7 @@
import * as util from "util";
import * as fs from "fs";
import { EventEmitter } from "events";
import * as path from "path";
const Reset = "\x1b[0m"
const Bright = "\x1b[1m"
@ -68,7 +69,7 @@ export class Logging {
}
let m = "";
(<any>error.stack).forEach(e => {
m += e.toString() + "\n";
m += e.toString() + " | ";
})
var message = error.name + " " + error.message + "\n" + m;
Logging.message(LoggingTypes.Error, [message]);
@ -168,9 +169,9 @@ export class Logging {
});
Logging.fileStream = fs.createWriteStream(this.logFileLocation + "all.log", { flags: "a" });
Logging.fileStream.write("\n\n");
Logging.fileStream.write("\n");
Logging.errorStream = fs.createWriteStream(this.logFileLocation + "error.log", { flags: "a" });
Logging.errorStream.write("\n\n");
Logging.errorStream.write("\n");
} catch (e) {
console.log(e);
}
@ -189,11 +190,8 @@ function _getCallerFile() {
while (err.stack.length) {
caller_file = (<any>err.stack).shift().getFileName();
if (current_file !== caller_file) {
let array = caller_file.split("/")
return array[array.length - 1];
}
console.log(caller_file);
if (current_file !== caller_file) return path.basename(caller_file);
}
} catch (err) { }
return undefined;