-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathServerInfo.js
90 lines (84 loc) · 2.94 KB
/
ServerInfo.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const mysql = require('./mysql')
exports.RegisterServerError = async (ErrorLocal, Description) => {
try {
var date = GetDate();
var time = GetTime();
var query = `insert into tbl_serverDetails (Local, date, time, Description) values (?,?,?,?);`
await mysql.execute(query, [ ErrorLocal, date, time, Description ])
console.log('Server error successfully inserted')
} catch (error) {
console.log('Error to insert server Error: ' + error)
}
}
function GetDate(){
var date = new Date()
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var formatterDay;
if (day < 10) {
formatterDay = '0'+ day;
} else {
formatterDay = day;
}
var formatterMonth;
if (month < 10) {
formatterMonth = '0'+ month;
} else {
formatterMonth = month;
}
return formatterDay +'/'+ formatterMonth +'/'+ year;
}
exports.GetDate = () => {
var date = new Date()
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var formatterDay;
if (day < 10) {
formatterDay = '0'+ day;
} else {
formatterDay = day;
}
var formatterMonth;
if (month < 10) {
formatterMonth = '0'+ month;
} else {
formatterMonth = month;
}
return formatterDay +'/'+ formatterMonth +'/'+ year;
}
function GetTime(){
var date = new Date();
var hour = date.getHours();
hour = (hour < 10 ? "0" : "") + hour;
var min = date.getMinutes();
min = (min < 10 ? "0" : "") + min;
return hour + ":" + min;
}
exports.GetTime = () => {
var date = new Date();
var hour = date.getHours();
hour = (hour < 10 ? "0" : "") + hour;
var min = date.getMinutes();
min = (min < 10 ? "0" : "") + min;
return hour + ":" + min;
}
// Method to print on console the Request Id
var requestId = 0;
exports.showRequestId = () => {
requestId++;
var getdate = GetDate() + " • " + GetTime();
if(requestId.toString().length == 1)
console.log("----------------------------------------------------\n------ ✅ Request Id: "
+ requestId + ` ${getdate} ✅ ------\n----------------------------------------------------`)
else if (requestId.toString().length == 2)
console.log("-----------------------------------------------------\n------ ✅ Request Id: "
+ requestId + ` ${getdate} ✅ ------\n-----------------------------------------------------`)
else if (requestId.toString().length == 3)
console.log("------------------------------------------------------\n------ ✅ Request Id: "
+ requestId + ` ${getdate} ✅ ------\n------------------------------------------------------`)
else
console.log("-------------------------------------------------------\n------ ✅ Request Id: "
+ requestId + ` ${getdate} ✅ ------\n-------------------------------------------------------`)
}