Files
infoscreen3/modules/cli.js
T
Petri Järvisalo a0875f8c1f Update Infoscreen3 to 1.6.4
* Update npm dependencies
* Change config to use environmental variables,
* Fix videos to actually show (modern browsers needs muted volume)
* Fix videos to load actually for lite and css views
* Provide zip with precompiled binaries for super-easy setup
2023-11-12 02:06:32 +02:00

63 lines
1.4 KiB
JavaScript

import 'dotenv/config'
import chalk from 'chalk';
let lastStamp = "";
export default {
error: function (error, title) {
if (title == null) {
title = "";
}
this.log(chalk.bold.red("[Error]" + title) + " " + error);
},
info: function (string, category) {
this.log(chalk.cyan("[" + (category || "Info") + "] ") + string);
},
debug: function (string) {
console.log(chalk.bold.black("[Debug] " + string));
},
success: function (string) {
this.log(string + chalk.green(" [Success]"));
},
log: function (string) {
if (process.env.DEBUG != "true") return;
let now = getDateTime();
if (lastStamp != now) {
lastStamp = now;
now = "\n" + now + "\n"
} else {
now = "";
}
console.log(now + string);
}
};
function getDateTime() {
var date = new Date();
var hour = date.getHours();
hour = (hour < 10 ? "0" : "") + hour;
var min = date.getMinutes();
min = (min < 10 ? "0" : "") + min;
var sec = date.getSeconds();
sec = (sec < 10 ? "0" : "") + sec;
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? "0" : "") + month;
var day = date.getDate();
day = (day < 10 ? "0" : "") + day;
return year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec;
}