mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
Logging
This commit is contained in:
parent
9cbaa42046
commit
366a8de8b5
5
.gitignore
vendored
5
.gitignore
vendored
@ -12,4 +12,7 @@ modules/ffmpeg/*
|
||||
!modules/ffmpeg/README.md
|
||||
.vscode/*
|
||||
|
||||
test.json
|
||||
test.json
|
||||
|
||||
*.log
|
||||
*.db
|
||||
@ -183,9 +183,6 @@
|
||||
protocol = 'https';
|
||||
}
|
||||
var localhostAdd = protocol + '://localhost:' + port;
|
||||
// var newtworkAdd = protocol + '://' + require('internal-ip').v4() + ':' + port;
|
||||
// console.log('Access mStream on the internet: '+protocol+'://' + ip + ':' + program.port);
|
||||
// var iAdd = protocol + '://' + ip + ':' + port;
|
||||
|
||||
var extraText = '';
|
||||
if(newSubscriber ===true){
|
||||
|
||||
3
logs/README.md
Normal file
3
logs/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Logs get stored here
|
||||
|
||||
To enable logging, use the `-L` flag
|
||||
@ -1,5 +1,4 @@
|
||||
const natupnp = require('nat-upnp');
|
||||
require('./logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
var tunnelInterval;
|
||||
|
||||
@ -40,6 +40,9 @@ exports.setup = function (args) {
|
||||
.option('-S, --skipimg', 'While skip parsing album art if flagged')
|
||||
.option('-P, --dbpause <dbpause>', 'Specify File Scan Pause Interval', /^\d+$/i, 0)
|
||||
|
||||
// Logs
|
||||
.option('-L, --logs <path>', 'Specify Database Filepath', './logs/mstream.db')
|
||||
|
||||
// JSON config
|
||||
.option('-j, --json <json>', 'Specify JSON Boot File')
|
||||
|
||||
@ -220,5 +223,10 @@ exports.setup = function (args) {
|
||||
program3.albumArtDir = program.images;
|
||||
}
|
||||
|
||||
// Logs
|
||||
if (program.logs) {
|
||||
program3.logs = { path: program.logs };
|
||||
}
|
||||
|
||||
return program3;
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const child = require('child_process');
|
||||
const fe = require('path');
|
||||
const mstreamReadPublicDB = require('../db-read/database-public-loki.js');
|
||||
require('../logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
exports.setup = function (mstream, program) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
const fe = require('path');
|
||||
const loki = require('lokijs');
|
||||
require('../logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
// Loki Collections
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
const archiver = require('archiver');
|
||||
const fe = require('path');
|
||||
require('./logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
exports.setup = function (mstream, program) {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const Busboy = require("busboy");
|
||||
const fs = require("fs");
|
||||
const fe = require("path");
|
||||
require('./logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
const masterFileTypesArray = ["mp3", "flac", "wav", "ogg", "aac", "m4a"];
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
// Websocket Server
|
||||
const WebSocketServer = require('ws').Server;
|
||||
const url = require('url');
|
||||
require('./logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
// list of currently connected clients (users)
|
||||
|
||||
@ -7,15 +7,26 @@ const myFormat = winston.format.printf(info => {
|
||||
const init = () => {
|
||||
winston.configure({
|
||||
transports: [
|
||||
new winston.transports.Console()
|
||||
new winston.transports.Console({
|
||||
format: winston.format.combine(
|
||||
winston.format.colorize(),
|
||||
winston.format.timestamp(),
|
||||
myFormat
|
||||
)
|
||||
})
|
||||
],
|
||||
format: winston.format.combine(
|
||||
winston.format.colorize(),
|
||||
winston.format.timestamp(),
|
||||
myFormat
|
||||
),
|
||||
exitOnError: false
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { init };
|
||||
const addFileLogger = (filepath) => {
|
||||
winston.add(new winston.transports.File({
|
||||
filename: filepath,
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.json()
|
||||
),
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports = { init, addFileLogger };
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
const crypto = require('crypto');
|
||||
require('./logger').init();
|
||||
const winston = require('winston');
|
||||
|
||||
exports.setup = function (mstream, program) {
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
const winston = require('winston');
|
||||
const uuidV4 = require('uuid/v4');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const loki = require('lokijs');
|
||||
const shareDB = new loki('sdhare.db');
|
||||
const shareDB = new loki('sdhare.db'); // TODO: Add this to config
|
||||
var shareCollection;
|
||||
shareDB.loadDatabase({}, err => {
|
||||
shareCollection = shareDB.getCollection('playlists');
|
||||
|
||||
28
mstream.js
28
mstream.js
@ -1,4 +1,5 @@
|
||||
require('./modules/logger').init();
|
||||
const logger = require('./modules/logger');
|
||||
logger.init();
|
||||
const winston = require('winston');
|
||||
const express = require('express');
|
||||
const mstream = express();
|
||||
@ -6,9 +7,7 @@ const fs = require('fs');
|
||||
const fe = require('path');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
exports.logit = function (msg) {
|
||||
winston.info(msg);
|
||||
}
|
||||
exports.logit = function (msg) { /*Nothing. This is for electron*/ }
|
||||
|
||||
exports.addresses = {
|
||||
localhost: false,
|
||||
@ -16,7 +15,11 @@ exports.addresses = {
|
||||
internet: false
|
||||
}
|
||||
|
||||
exports.serveit = function (program, callback) {
|
||||
exports.serveit = function (program) {
|
||||
if (program.logs && program.logs.path) {
|
||||
logger.addFileLogger(program.logs.path);
|
||||
}
|
||||
|
||||
var server;
|
||||
|
||||
if (program.ssl && program.ssl.cert && program.ssl.key) {
|
||||
@ -186,11 +189,13 @@ exports.serveit = function (program, callback) {
|
||||
server.listen(program.port, function () {
|
||||
let protocol = program.ssl && program.ssl.cert && program.ssl.key ? 'https' : 'http';
|
||||
exports.addresses.local = protocol + '://localhost:' + program.port;
|
||||
exports.logit('Access mStream locally: ' + exports.addresses.local);
|
||||
winston.info(`Access mStream locally: ${exports.addresses.local}`);
|
||||
exports.logit(`Access mStream locally: ${exports.addresses.local}`);
|
||||
|
||||
require('internal-ip').v4().then(ip => {
|
||||
exports.addresses.network = protocol + '://' + ip + ':' + program.port;
|
||||
exports.logit('Access mStream on your local network: ' + exports.addresses.network);
|
||||
winston.info(`Access mStream on your local network: ${exports.addresses.network}`);
|
||||
exports.logit(`Access mStream on your local network: ${exports.addresses.network}`);
|
||||
});
|
||||
|
||||
// Handle Port Forwarding
|
||||
@ -200,14 +205,17 @@ exports.serveit = function (program, callback) {
|
||||
if (status === true) {
|
||||
require('public-ip').v4().then(ip => {
|
||||
exports.addresses.internet = protocol + '://' + ip + ':' + program.port;
|
||||
exports.logit('Access mStream on your local network:the internet: ' + exports.addresses.internet);
|
||||
winston.info(`Access mStream on your local network:the internet: ${exports.addresses.internet}`);
|
||||
exports.logit(`Access mStream on your local network:the internet: ${exports.addresses.internet}`);
|
||||
});
|
||||
} else {
|
||||
exports.logit('Port Forwarding Failed. The server is runnig but you will have to configure your own port forwarding');
|
||||
winston.error('Port Forwarding Failed. The server is running but you will have to configure your own port forwarding');
|
||||
exports.logit('Port Forwarding Failed. The server is running but you will have to configure your own port forwarding');
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
exports.logit('Port Forwarding Failed. The server is runnig but you will have to configure your own port forwarding');
|
||||
exports.logit('Port Forwarding Failed. The server is running but you will have to configure your own port forwarding');
|
||||
winston.error('Port Forwarding Failed. The server is running but you will have to configure your own port forwarding');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user