Skip to content

Commit

Permalink
Improve logging statements and levels
Browse files Browse the repository at this point in the history
  • Loading branch information
TheConnMan committed Mar 25, 2017
1 parent dc4c448 commit b4f2b12
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions api/controllers/ApiController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const log4js = require('log4js');
const logger = log4js.getLogger('api/controllers/api');

var users = {};
var recentlyLeft = [];

Expand All @@ -12,6 +15,7 @@ module.exports = {

var index = recentlyLeft.indexOf(username);
if (index === -1) {
logger.debug(users[id] + ' entered the room');
ChatService.addMachineMessage(users[id] + ' entered the room', username, 'userEnter');
} else {
recentlyLeft.splice(index, 1);
Expand Down Expand Up @@ -141,6 +145,7 @@ function userDisconnected(username) {
var index = recentlyLeft.indexOf(username);
if (index !== -1) {
recentlyLeft.splice(index, 1);
logger.debug(username + ' left the room');
ChatService.addMachineMessage(username + ' left the room', username, 'userLeft');
emitListeners();
if (Object.keys(users).length === 0) {
Expand Down
5 changes: 2 additions & 3 deletions api/services/SyncService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Promise = require('promise');
var log4js = require('log4js');
var logger = log4js.getLogger('api/services/SyncService');
var logger = log4js.getLogger('api/services/sync');

var SlackWebhook = require('slack-webhook');
var slack = sails.config.globals.slackWebhook ? new SlackWebhook(sails.config.globals.slackWebhook, {
Expand Down Expand Up @@ -124,7 +124,7 @@ function endCurrentVideo(username) {
}
current.playing = false;
current.save(function() {
logger.info('Publishing end song ' + current.key);
logger.debug('Publishing end song ' + current.key);
Video.publishUpdate(current.id, current);
findNextVideo(current);
});
Expand Down Expand Up @@ -152,7 +152,6 @@ function startVideo(video) {
video.playing = true;
video.played = true;
video.startTime = new Date();
logger.info('Setting timeout');
videoTimeout = setTimeout(endCurrentVideo, video.duration);
video.save(() => {
Video.publishUpdate(video.id, video);
Expand Down
4 changes: 2 additions & 2 deletions api/services/YouTubeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const request = require('request');
const moment = require('moment');
const log4js = require('log4js');
const Youtube = require("youtube-api");
const logger = log4js.getLogger();
const logger = log4js.getLogger('api/services/youtube');

Youtube.authenticate({
type: 'key',
Expand Down Expand Up @@ -40,7 +40,7 @@ function getYouTubeVideo(key, user, canSave=true) {
resolve(video);
});
} catch (e) {
logger.debug(`Video ${key}: ${e}`);
logger.error(`Error parsing video ${key}: ${e}`);
resolve(null);
}
} else {
Expand Down

0 comments on commit b4f2b12

Please sign in to comment.