add more query log for dev env

This commit is contained in:
LouisLam
2021-08-17 02:09:40 +08:00
parent 798f39acf0
commit eed6d3e847
5 changed files with 60 additions and 15 deletions

View File

@@ -4,6 +4,9 @@
// Frontend uses util.ts
// Need to run "tsc" to compile if there are any changes.
import * as dayjs from "dayjs";
export const isDev = process.env.NODE_ENV === "development";
export const appName = "Uptime Kuma";
export const DOWN = 0;
export const UP = 1;
@@ -39,7 +42,7 @@ export function ucfirst(str) {
}
export function debug(msg) {
if (process.env.NODE_ENV === "development") {
if (isDev) {
console.log(msg);
}
}
@@ -52,7 +55,7 @@ export function polyfill() {
* @license MIT
*/
if (!String.prototype.replaceAll) {
String.prototype.replaceAll = function(str, newStr) {
String.prototype.replaceAll = function (str, newStr) {
// If a regex pattern
if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") {
@@ -65,3 +68,15 @@ export function polyfill() {
};
}
}
export class TimeLogger {
constructor() {
this.startTime = dayjs().valueOf();
}
print(name) {
if (isDev) {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms")
}
}
}