Merge pull request #2506 from thelounge/xpaw/rm-logs-format

Remove ability to change date format and timezone
This commit is contained in:
Pavel Djundik 2018-06-05 14:55:44 +03:00 committed by GitHub
commit 3248f0db1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 39 deletions

View File

@ -161,33 +161,6 @@ module.exports = {
//
messageStorage: ["sqlite", "text"],
//
// Log settings
//
// Logging has to be enabled per user. If enabled, logs will be stored in
// the 'logs/<user>/<network>/' folder.
//
// @type object
// @default {}
//
logs: {
//
// Timestamp format
//
// @type string
// @default "YYYY-MM-DD HH:mm:ss"
//
format: "YYYY-MM-DD HH:mm:ss",
//
// Timezone
//
// @type string
// @default "UTC+00:00"
//
timezone: "UTC+00:00",
},
//
// Maximum number of history lines per channel
//

View File

@ -8,6 +8,7 @@ const fs = require("fs");
const net = require("net");
const bcrypt = require("bcryptjs");
const colors = require("chalk");
const moment = require("moment");
let homePath;
let configPath;
@ -30,6 +31,7 @@ const Helper = {
setHome,
getVersion,
getGitCommit,
getHumanDate,
ip2hex,
mergeConfig,
getDefaultNick,
@ -205,6 +207,10 @@ function passwordCompare(password, expected) {
return bcrypt.compare(password, expected);
}
function getHumanDate() {
return moment().format("YYYY-MM-DD HH:mm:ss");
}
function getDefaultNick() {
if (!this.config.defaults.nick) {
return "thelounge";

View File

@ -1,16 +1,11 @@
"use strict";
const colors = require("chalk");
const moment = require("moment");
const read = require("read");
const Helper = require("./helper");
function timestamp() {
const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss";
const tz = Helper.config.logs.timezone || "UTC+00:00";
const time = moment().utcOffset(tz).format(format);
return colors.dim(time);
return colors.dim(Helper.getHumanDate());
}
module.exports = {

View File

@ -3,7 +3,6 @@
const fs = require("fs");
const fsextra = require("fs-extra");
const path = require("path");
const moment = require("moment");
const filenamify = require("filenamify");
const Helper = require("../../helper");
@ -40,11 +39,7 @@ class TextFileMessageStorage {
return;
}
const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss";
const tz = Helper.config.logs.timezone || "UTC+00:00";
const time = moment(msg.time).utcOffset(tz).format(format);
let line = `[${time}] `;
let line = `[${Helper.getHumanDate()}] `;
if (msg.type === "message") {
// Format:

View File

@ -2,6 +2,7 @@
const expect = require("chai").expect;
const os = require("os");
const moment = require("moment");
const Helper = require("../../src/helper");
describe("Helper", function() {
@ -52,4 +53,8 @@ describe("Helper", function() {
expect(version).to.match(/v[0-9]+\.[0-9]+\.[0-9]+/);
});
});
describe("#getHumanDate()", function() {
expect(Helper.getHumanDate()).to.equal(moment().format("YYYY-MM-DD HH:mm:ss"));
});
});