Added simple file logging
This commit is contained in:
parent
3f1157b080
commit
600db66d73
|
@ -1,3 +1,4 @@
|
||||||
|
log
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/visualstudiocode,node
|
# Created by https://www.gitignore.io/api/visualstudiocode,node
|
||||||
|
|
||||||
|
|
7
log.js
7
log.js
|
@ -1,6 +1,8 @@
|
||||||
var console = require("console");
|
var console = require("console");
|
||||||
var FileWriter = require("simple-file-writer");
|
var FileWriter = require("simple-file-writer");
|
||||||
|
|
||||||
|
var logWriter = new FileWriter("./log");
|
||||||
|
|
||||||
var latestLog = "";
|
var latestLog = "";
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
|
@ -8,7 +10,10 @@ function log(message) {
|
||||||
latestLog = message; //spam reduction
|
latestLog = message; //spam reduction
|
||||||
|
|
||||||
//attach a formatted date string to the beginning of everything we log
|
//attach a formatted date string to the beginning of everything we log
|
||||||
console.log(new Date().toLocaleString() + " " + message);
|
var dateMessage = new Date().toLocaleString() + " " + message;
|
||||||
|
|
||||||
|
console.log(dateMessage);
|
||||||
|
logWriter.write(dateMessage + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue