Files
wx_epaper_lite/pages/logs/log_func.js
风不出来 bdfae48fc2 000
2024-06-04 19:59:44 +08:00

43 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// logs.js
// const util = require('../../utils/util.js')
const app = getApp()
//调试信息相关函数
//在log窗体中显示打印信息。
function printLog(log) {
var temp = printTimer() + ' ' + log
var logs = wx.getStorageSync('logs')
logs= temp + '\n' + logs
wx.setStorageSync('logs', logs)
app.globalData.logs=logs
}
//打印log时增加时间戳。
function printTimer() {
var date = new Date();
// var year = date.getFullYear(); //获取当前年份
// var month = date.getMonth() + 1; //获取当前月份
// var day = date.getDate(); //获取当前日期
var hour = date.getHours(); //获取当前小时
var minute = date.getMinutes(); //获取当前分钟
var second = date.getSeconds(); //获取当前秒钟
hour = hour < 10 ? "0" + hour : hour;
minute = minute < 10 ? "0" + minute : minute;
second = second < 10 ? "0" + second : second;
// console.log(year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second); //输出当前时间
// console.log(hour + ':' + minute + ':' + second); //输出当前时间
var log_temp = hour + ':' + minute + ':' + second + ':'
// var logs = this.data.logs;
// logs.push( log_temp);
return log_temp
// this.setData({log_list: logs.join( '')})
}
module.exports = {
printLog,
}