Browse Source

Added simple file logging

shorten
benji7425 4 years ago
parent
commit
600db66d73
  1. 1
      .gitignore
  2. 7
      log.js

1
.gitignore

@ -1,3 +1,4 @@
log
# Created by https://www.gitignore.io/api/visualstudiocode,node

7
log.js

@ -1,6 +1,8 @@
var console = require("console");
var FileWriter = require("simple-file-writer");
var logWriter = new FileWriter("./log");
var latestLog = "";
function log(message) {
@ -8,7 +10,10 @@ function log(message) {
latestLog = message; //spam reduction
//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…
Cancel
Save