finished logger paths and details

This commit is contained in:
bill bittner 2017-06-19 20:22:23 -07:00
parent 5f7177540c
commit dd70c19b64
9 changed files with 26 additions and 25 deletions

View file

@ -10,7 +10,7 @@
"PublishUploadPath": "none" "PublishUploadPath": "none"
}, },
"Logging": { "Logging": {
"LogLevel": "silly", "LogLevel": "none",
"LogDirectory": "C:\\lbry\\speech\\logs\\" "LogDirectory": "none"
} }
} }

View file

@ -10,6 +10,7 @@
"PublishUploadPath": "C:\\lbry\\speech\\hosted_content" "PublishUploadPath": "C:\\lbry\\speech\\hosted_content"
}, },
"Logging": { "Logging": {
"LogLevel": "debug" "LogLevel": "debug",
"LogDirectory": "C:\\lbry\\speech\\logs\\"
} }
} }

View file

@ -10,6 +10,7 @@
"PublishUploadPath": "/home/lbry/Downloads/" "PublishUploadPath": "/home/lbry/Downloads/"
}, },
"Logging": { "Logging": {
"LogLevel": "verbose" "LogLevel": "debug",
"LogDirectory": "/home/lbry/Logs"
} }
} }

View file

@ -10,6 +10,7 @@
"PublishUploadPath": "/home/ubuntu/Downloads/" "PublishUploadPath": "/home/ubuntu/Downloads/"
}, },
"Logging": { "Logging": {
"LogLevel": "info" "LogLevel": "debug",
"LogDirectory": "/home/ubuntu/Logs"
} }
} }

View file

@ -44,6 +44,7 @@ module.exports = {
lbryApi lbryApi
.publishClaim(publishParams, fileName, fileType) .publishClaim(publishParams, fileName, fileType)
.then(result => { .then(result => {
logger.info(`Successfully published ${fileName}`);
visitor.event('Publish Route', 'Publish Success', filePath).send(); visitor.event('Publish Route', 'Publish Success', filePath).send();
socket.emit('publish-complete', { name: claim, result }); socket.emit('publish-complete', { name: claim, result });
}) })

View file

@ -35,13 +35,14 @@ module.exports = {
.then(claim => { .then(claim => {
// if a matching claim is found locally... // if a matching claim is found locally...
if (claim) { if (claim) {
logger.debug(`A mysql record was found for ${claimId}`);
// if the outpoint's match return it // if the outpoint's match return it
if (claim.dataValues.outpoint === freePublicClaimOutpoint) { if (claim.dataValues.outpoint === freePublicClaimOutpoint) {
logger.debug(`local outpoint matched for ${name} ${claimId} `); logger.debug(`local outpoint matched for ${claimId}`);
resolve(claim.dataValues); resolve(claim.dataValues);
// if the outpoint's don't match, fetch updated claim // if the outpoint's don't match, fetch updated claim
} else { } else {
logger.debug(`local outpoint did not match ${name} ${claimId}`); logger.debug(`local outpoint did not match for ${claimId}`);
getClaimAndHandleResponse(freePublicClaimUri, resolve, reject); getClaimAndHandleResponse(freePublicClaimUri, resolve, reject);
} }
// ... otherwise use daemon to retrieve it // ... otherwise use daemon to retrieve it
@ -73,14 +74,14 @@ module.exports = {
.then(claim => { .then(claim => {
// if a found locally... // if a found locally...
if (claim) { if (claim) {
logger.debug(`A File record was found for ${claimName}/${claimId}`); logger.debug(`A mysql record was found for ${claimId}`);
// if the outpoint's match return it // if the outpoint's match return it
if (claim.dataValues.outpoint === resolvedOutpoint) { if (claim.dataValues.outpoint === resolvedOutpoint) {
logger.debug('local outpoint matched'); logger.debug(`local outpoint matched for ${claimId}`);
resolve(claim.dataValues); resolve(claim.dataValues);
// if the outpoint's don't match, fetch updated claim // if the outpoint's don't match, fetch updated claim
} else { } else {
logger.debug('local outpoint did not match'); logger.debug(`local outpoint did not match for ${claimId}`);
getClaimAndHandleResponse(uri, resolve, reject); getClaimAndHandleResponse(uri, resolve, reject);
} }
// ... otherwise use daemon to retrieve it // ... otherwise use daemon to retrieve it

View file

@ -1,5 +1,4 @@
const fs = require('fs'); const fs = require('fs');
const tsFormat = () => (new Date()).toLocaleTimeString();
module.exports = (winston, logLevel, logDir) => { module.exports = (winston, logLevel, logDir) => {
if (!fs.existsSync(logDir)) { if (!fs.existsSync(logDir)) {
@ -15,21 +14,18 @@ module.exports = (winston, logLevel, logDir) => {
prettyPrint: true, prettyPrint: true,
}), }),
new (winston.transports.File)({ new (winston.transports.File)({
filename : `${logDir}speechLogs.log`, filename : `${logDir}speechLogs.log`,
level : logLevel, level : logLevel,
json : false, json : false,
timestamp : tsFormat, timestamp : true,
colorize : true, colorize : true,
prettyPrint: true, prettyPrint : true,
handleExceptions : true,
humanReadableUnhandledException: true,
}), }),
], ],
}); });
winston.handleExceptions(new winston.transports.File({
filename : `${logDir}uncaughtExceptions.log`,
humanReadableUnhandledException: true,
}));
winston.error('Level 0'); winston.error('Level 0');
winston.warn('Level 1'); winston.warn('Level 1');
winston.info('Level 2'); winston.info('Level 2');

View file

@ -3,7 +3,7 @@ const serveController = require('../controllers/serveController.js');
const logger = require('winston'); const logger = require('winston');
function serveFile ({ fileName, fileType, filePath }, res) { function serveFile ({ fileName, fileType, filePath }, res) {
logger.info(`serving file ${fileName} from ${filePath}`); logger.info(`serving file ${fileName}`);
// set default options // set default options
const options = { const options = {
headers: { headers: {

View file

@ -14,7 +14,7 @@ module.exports = (app, siofu, hostedContentPath, ua, googleAnalyticsId) => {
uploader.dir = hostedContentPath; uploader.dir = hostedContentPath;
uploader.listen(socket); uploader.listen(socket);
uploader.on('start', ({ file }) => { uploader.on('start', ({ file }) => {
logger.info('Client started an upload', file); logger.info('client started an upload:', file.name);
// server side test to make sure file is not a bad file type // server side test to make sure file is not a bad file type
if (/\.exe$/.test(file.name)) { if (/\.exe$/.test(file.name)) {
uploader.abort(file.id, socket); uploader.abort(file.id, socket);
@ -26,7 +26,7 @@ module.exports = (app, siofu, hostedContentPath, ua, googleAnalyticsId) => {
}); });
uploader.on('saved', ({ file }) => { uploader.on('saved', ({ file }) => {
if (file.success) { if (file.success) {
logger.info(`Client successfully uploaded ${file.name}`); logger.debug(`Client successfully uploaded ${file.name}`);
socket.emit('publish-status', 'file upload successfully completed'); socket.emit('publish-status', 'file upload successfully completed');
publishController.publish(file.meta.name, file.name, file.pathName, file.meta.type, file.meta.license, file.meta.nsfw, socket, visitor); publishController.publish(file.meta.name, file.name, file.pathName, file.meta.type, file.meta.license, file.meta.nsfw, socket, visitor);
} else { } else {