-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogging.js
More file actions
37 lines (31 loc) · 1.03 KB
/
Copy pathLogging.js
File metadata and controls
37 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
function Logging(){
this.file = "入退室管理.log";
}
Logging.prototype.write = function(message){
const datedata = getTimestamp();
message = datedata + message + "\n";
fs.appendFile(this.file, message, 'utf8', function(err){
if(err) console.log(err);
});
}
function getTimestamp(){
const dt = new Date();
const year = dt.getFullYear();
const month = dt.getMonth()+1;
const date = dt.getDate();
const dateT = ["日","月","火","水","木","金","土"];
const day = dateT[dt.getDay()];
const hours = dt.getHours();
const minutes = dt.getMinutes();
const seconds = dt.getSeconds();
const datedata = year + "/"+
month + "/"+
date + "/("+
day + ") "+
hours + ":"+
minutes + ":"+
seconds + " ";
return datedata;
}
module.exports = Logging;