Commit bea1c2b9 by 陈思聪

fix: console.log打印带时间戳

parent edffbf63
{
const newLog = function () {
const arr = []
arr.push(getCurrentTime())
const res = [...arr,...Array.from(arguments)]
arguments.callee.oLog.apply(this, res);
};
// const newError = function () {
// const arr = []
// arr.push(getCurrentTime())
// const res = [...arr,...Array.from(arguments)]
// arguments.callee.oError.apply(this, res);
// };
newLog.oLog = console.log;
// newError.oError = console.error;
console.log = newLog;
// console.error = newError;
}
const getCurrentTime = () => {
let date = new Date();
let y = date.getFullYear();
let m = date.getMonth() + 1 >= 10 ? date.getMonth() + 1 : `0` + (date.getMonth() + 1);
let d = date.getDate() >= 10 ? date.getDate() : `0` + date.getDate();
let h = date.getHours()>= 10 ? date.getHours() : `0` + date.getHours();
let min = date.getMinutes()>= 10 ? date.getMinutes() : `0` + date.getMinutes();
let s = date.getSeconds()>= 10 ? date.getSeconds() : `0` + date.getSeconds();
return `${y}-${m}-${d} ${h}:${min}:${s}`;
}
\ No newline at end of file
require("./app/base/utils/log")
var http = require('http');
var express = require('express');
var app = express();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment