mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-10-11 12:39:21 +08:00
separate log functions
This commit is contained in:
@@ -435,7 +435,7 @@ dayjs.extend(timezone);
|
||||
|
||||
import { timezoneList, setPageLocale } from "../util-frontend";
|
||||
import { useToast } from "vue-toastification";
|
||||
import { log } from "../util.ts";
|
||||
import { log_debug } from "../util.ts";
|
||||
|
||||
const toast = useToast();
|
||||
|
||||
@@ -639,20 +639,20 @@ export default {
|
||||
this.loadDatabaseSize();
|
||||
toast.success("Done");
|
||||
} else {
|
||||
log("settings", res, "debug");
|
||||
log_debug("settings", res);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
loadDatabaseSize() {
|
||||
log("settings", "load database size", "debug");
|
||||
log_debug("settings", "load database size");
|
||||
this.$root.getSocket().emit("getDatabaseSize", (res) => {
|
||||
|
||||
if (res.ok) {
|
||||
this.databaseSize = res.size;
|
||||
log("settings", "database size: " + res.size, "debug");
|
||||
log_debug("settings", "database size: " + res.size);
|
||||
} else {
|
||||
log("settings", res, "debug");
|
||||
log_debug("settings", res);
|
||||
}
|
||||
|
||||
});
|
||||
|
21
src/util.js
21
src/util.js
@@ -7,7 +7,7 @@
|
||||
// Backend uses the compiled file util.js
|
||||
// Frontend uses util.ts
|
||||
exports.__esModule = true;
|
||||
exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.ucfirst = exports.sleep = exports.flipStatus = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
||||
exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log_debug = exports.log_error = exports.log_warn = exports.log_info = exports.ucfirst = exports.sleep = exports.flipStatus = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
||||
var _dayjs = require("dayjs");
|
||||
var dayjs = _dayjs;
|
||||
exports.isDev = process.env.NODE_ENV === "development";
|
||||
@@ -44,9 +44,7 @@ function ucfirst(str) {
|
||||
return firstLetter.toUpperCase() + str.substr(1);
|
||||
}
|
||||
exports.ucfirst = ucfirst;
|
||||
// log levels = info / warn / error / debug
|
||||
function log(module, msg, level) {
|
||||
if (level === void 0) { level = "info"; }
|
||||
module = module.toUpperCase();
|
||||
level = level.toUpperCase();
|
||||
var now = new Date().toISOString();
|
||||
@@ -69,7 +67,22 @@ function log(module, msg, level) {
|
||||
console.log(formattedMessage);
|
||||
}
|
||||
}
|
||||
exports.log = log;
|
||||
function log_info(module, msg) {
|
||||
log(module, msg, "info");
|
||||
}
|
||||
exports.log_info = log_info;
|
||||
function log_warn(module, msg) {
|
||||
log(module, msg, "warn");
|
||||
}
|
||||
exports.log_warn = log_warn;
|
||||
function log_error(module, msg) {
|
||||
log(module, msg, "error");
|
||||
}
|
||||
exports.log_error = log_error;
|
||||
function log_debug(module, msg) {
|
||||
log(module, msg, "debug");
|
||||
}
|
||||
exports.log_debug = log_debug;
|
||||
function polyfill() {
|
||||
/**
|
||||
* String.prototype.replaceAll() polyfill
|
||||
|
18
src/util.ts
18
src/util.ts
@@ -49,8 +49,7 @@ export function ucfirst(str: string) {
|
||||
return firstLetter.toUpperCase() + str.substr(1);
|
||||
}
|
||||
|
||||
// log levels = info / warn / error / debug
|
||||
export function log(module: string, msg: any, level:string = "info") {
|
||||
function log(module: string, msg: any, level:string) {
|
||||
module = module.toUpperCase();
|
||||
level = level.toUpperCase();
|
||||
|
||||
@@ -72,6 +71,21 @@ export function log(module: string, msg: any, level:string = "info") {
|
||||
}
|
||||
}
|
||||
|
||||
export function log_info(module: string, msg: any) {
|
||||
log(module, msg, "info");
|
||||
}
|
||||
|
||||
export function log_warn(module: string, msg: any) {
|
||||
log(module, msg, "warn");
|
||||
}
|
||||
|
||||
export function log_error(module: string, msg: any) {
|
||||
log(module, msg, "error");
|
||||
}
|
||||
|
||||
export function log_debug(module: string, msg: any) {
|
||||
log(module, msg, "debug");
|
||||
}
|
||||
|
||||
declare global { interface String { replaceAll(str: string, newStr: string): string; } }
|
||||
|
||||
|
Reference in New Issue
Block a user