Refactor logging
This commit is contained in:
parent
b1a328d2e0
commit
8306d2d1b6
29 changed files with 268 additions and 194 deletions
|
|
@ -1,8 +1,5 @@
|
|||
var Logger = require("../logger");
|
||||
var ChannelModule = require("./module");
|
||||
var Flags = require("../flags");
|
||||
var Account = require("../account");
|
||||
var util = require("../utilities");
|
||||
var fs = require("graceful-fs");
|
||||
var path = require("path");
|
||||
var sio = require("socket.io");
|
||||
|
|
@ -12,6 +9,10 @@ import { ChannelStateSizeError } from '../errors';
|
|||
import Promise from 'bluebird';
|
||||
import { EventEmitter } from 'events';
|
||||
import { throttle } from '../util/throttle';
|
||||
import Logger from '../logger';
|
||||
import { LoggerFactory } from '@calzoneman/jsli';
|
||||
|
||||
const LOGGER = LoggerFactory.getLogger('channel');
|
||||
|
||||
const USERCOUNT_THROTTLE = 10000;
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ class ReferenceCounter {
|
|||
delete this.references[caller];
|
||||
}
|
||||
} else {
|
||||
Logger.errlog.log("ReferenceCounter::unref() called by caller [" +
|
||||
LOGGER.error("ReferenceCounter::unref() called by caller [" +
|
||||
caller + "] but this caller had no active references! " +
|
||||
`(channel: ${this.channelName})`);
|
||||
}
|
||||
|
|
@ -56,7 +57,7 @@ class ReferenceCounter {
|
|||
checkRefCount() {
|
||||
if (this.refCount === 0) {
|
||||
if (Object.keys(this.references).length > 0) {
|
||||
Logger.errlog.log("ReferenceCounter::refCount reached 0 but still had " +
|
||||
LOGGER.error("ReferenceCounter::refCount reached 0 but still had " +
|
||||
"active references: " +
|
||||
JSON.stringify(Object.keys(this.references)) +
|
||||
` (channel: ${this.channelName})`);
|
||||
|
|
@ -64,7 +65,7 @@ class ReferenceCounter {
|
|||
this.refCount += this.references[caller];
|
||||
}
|
||||
} else if (this.channel.users.length > 0) {
|
||||
Logger.errlog.log("ReferenceCounter::refCount reached 0 but still had " +
|
||||
LOGGER.error("ReferenceCounter::refCount reached 0 but still had " +
|
||||
this.channel.users.length + " active users" +
|
||||
` (channel: ${this.channelName})`);
|
||||
this.refCount = this.channel.users.length;
|
||||
|
|
@ -208,7 +209,7 @@ Channel.prototype.loadState = function () {
|
|||
try {
|
||||
this.modules[m].load(data);
|
||||
} catch (e) {
|
||||
Logger.errlog.log("Failed to load module " + m + " for channel " +
|
||||
LOGGER.error("Failed to load module " + m + " for channel " +
|
||||
this.uniqueName);
|
||||
}
|
||||
});
|
||||
|
|
@ -219,7 +220,7 @@ Channel.prototype.loadState = function () {
|
|||
"enforced by this server. Please contact an administrator " +
|
||||
"for assistance.";
|
||||
|
||||
Logger.errlog.log(err.stack);
|
||||
LOGGER.error(err.stack);
|
||||
errorLoad(message, false);
|
||||
}).catch(err => {
|
||||
if (err.code === 'ENOENT') {
|
||||
|
|
@ -233,7 +234,7 @@ Channel.prototype.loadState = function () {
|
|||
"disk. Please contact an administrator for assistance. " +
|
||||
`The error was: ${err}.`;
|
||||
|
||||
Logger.errlog.log(err.stack);
|
||||
LOGGER.error(err.stack);
|
||||
errorLoad(message);
|
||||
}
|
||||
});
|
||||
|
|
@ -369,7 +370,7 @@ Channel.prototype.acceptUser = function (user) {
|
|||
user.autoAFK();
|
||||
user.socket.on("readChanLog", this.handleReadLog.bind(this, user));
|
||||
|
||||
Logger.syslog.log(user.realip + " joined " + this.name);
|
||||
LOGGER.info(user.realip + " joined " + this.name);
|
||||
if (user.socket._isUsingTor) {
|
||||
if (this.modules.options && this.modules.options.get("torbanned")) {
|
||||
user.kick("This channel has banned connections from Tor.");
|
||||
|
|
@ -420,7 +421,7 @@ Channel.prototype.acceptUser = function (user) {
|
|||
|
||||
Channel.prototype.partUser = function (user) {
|
||||
if (!this.logger) {
|
||||
Logger.errlog.log("partUser called on dead channel");
|
||||
LOGGER.error("partUser called on dead channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
var FilterList = require("cytubefilters");
|
||||
var ChannelModule = require("./module");
|
||||
var Logger = require("../logger");
|
||||
import { LoggerFactory } from '@calzoneman/jsli';
|
||||
|
||||
const LOGGER = LoggerFactory.getLogger('filters');
|
||||
|
||||
/*
|
||||
* Converts JavaScript-style replacements ($1, $2, etc.) with
|
||||
|
|
@ -76,7 +78,7 @@ ChatFilterModule.prototype.load = function (data) {
|
|||
try {
|
||||
this.filters = new FilterList(filters);
|
||||
} catch (e) {
|
||||
Logger.errlog.log("Filter load failed: " + e + " (channel:" +
|
||||
LOGGER.error("Filter load failed: " + e + " (channel:" +
|
||||
this.channel.name);
|
||||
this.channel.logger.log("Failed to load filters: " + e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
|
|||
var ChannelModule = require("./module");
|
||||
var Config = require("../config");
|
||||
var InfoGetter = require("../get-info");
|
||||
var Logger = require("../logger");
|
||||
import { LoggerFactory } from '@calzoneman/jsli';
|
||||
|
||||
const LOGGER = LoggerFactory.getLogger('mediarefresher');
|
||||
|
||||
function MediaRefresherModule(channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
|
|
@ -55,7 +57,7 @@ MediaRefresherModule.prototype.unload = function () {
|
|||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
} catch (error) {
|
||||
Logger.errlog.log(error.stack);
|
||||
LOGGER.error(error.stack);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -94,7 +96,7 @@ MediaRefresherModule.prototype.initVimeo = function (data, cb) {
|
|||
|
||||
if (cb) cb();
|
||||
}).catch(function (err) {
|
||||
Logger.errlog.log("Unexpected vimeo::extract() fail: " + err.stack);
|
||||
LOGGER.error("Unexpected vimeo::extract() fail: " + err.stack);
|
||||
if (cb) cb();
|
||||
}).finally(() => {
|
||||
self.channel.refCounter.unref("MediaRefresherModule::initVimeo");
|
||||
|
|
@ -145,7 +147,7 @@ MediaRefresherModule.prototype.refreshGoogleDocs = function (media, cb) {
|
|||
if (err) {
|
||||
self.channel.logger.log("[mediarefresher] Google Docs refresh failed: " +
|
||||
err);
|
||||
Logger.errlog.log("Google Docs refresh failed for ID " + media.id +
|
||||
LOGGER.error("Google Docs refresh failed for ID " + media.id +
|
||||
": " + err);
|
||||
self.channel.refCounter.unref("MediaRefresherModule::refreshGoogleDocs");
|
||||
if (cb) cb();
|
||||
|
|
@ -204,7 +206,7 @@ MediaRefresherModule.prototype.initGooglePlus = function (media, cb) {
|
|||
if (err) {
|
||||
self.channel.logger.log("[mediarefresher] Google+ refresh failed: " +
|
||||
err);
|
||||
Logger.errlog.log("Google+ refresh failed for ID " + media.id +
|
||||
LOGGER.error("Google+ refresh failed for ID " + media.id +
|
||||
": " + err);
|
||||
self.channel.refCounter.unref("MediaRefresherModule::initGooglePlus");
|
||||
if (cb) cb();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ var InfoGetter = require("../get-info");
|
|||
var Config = require("../config");
|
||||
var Flags = require("../flags");
|
||||
var db = require("../database");
|
||||
var Logger = require("../logger");
|
||||
var CustomEmbedFilter = require("../customembed").filter;
|
||||
var XSS = require("../xss");
|
||||
import { LoggerFactory } from '@calzoneman/jsli';
|
||||
|
||||
const LOGGER = LoggerFactory.getLogger('playlist');
|
||||
|
||||
const MAX_ITEMS = Config.get("playlist.max-items");
|
||||
// Limit requestPlaylist to once per 60 seconds
|
||||
|
|
@ -928,7 +930,7 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
|
|||
const limit = this.channel.modules.options.get("playlist_max_duration_per_user");
|
||||
const totalDuration = usersItems.map(item => item.media.seconds).reduce((a, b) => a + b, 0) + media.seconds;
|
||||
if (isNaN(totalDuration)) {
|
||||
Logger.errlog.log("playlist_max_duration_per_user check calculated NaN: " + require('util').inspect(usersItems));
|
||||
LOGGER.error("playlist_max_duration_per_user check calculated NaN: " + require('util').inspect(usersItems));
|
||||
} else if (totalDuration >= limit && !this.channel.modules.permissions.canExceedMaxDurationPerUser(user)) {
|
||||
return qfail("Channel limit exceeded: maximum total playlist time per user");
|
||||
}
|
||||
|
|
@ -1356,9 +1358,9 @@ PlaylistModule.prototype.handleQueuePlaylist = function (user, data) {
|
|||
self._addItem(m, qdata, user);
|
||||
});
|
||||
} catch (e) {
|
||||
Logger.errlog.log("Loading user playlist failed!");
|
||||
Logger.errlog.log("PL: " + user.getName() + "-" + data.name);
|
||||
Logger.errlog.log(e.stack);
|
||||
LOGGER.error("Loading user playlist failed!");
|
||||
LOGGER.error("PL: " + user.getName() + "-" + data.name);
|
||||
LOGGER.error(e.stack);
|
||||
user.socket.emit("queueFail", {
|
||||
msg: "Internal error occurred when loading playlist.",
|
||||
link: null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue