Skip to content

Commit

Permalink
Adds support for --verbose and verbose option when running ParseServer
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Apr 7, 2016
1 parent 325d09c commit f8ebcc9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ParseServer {
},
liveQuery = {},
sessionLength = 31536000, // 1 Year in seconds
verbose = false,
}) {
// Initialize the node client SDK automatically
Parse.initialize(appId, javascriptKey || 'unused', masterKey);
Expand Down Expand Up @@ -149,6 +150,9 @@ class ParseServer {
}
}

if (verbose || process.env.VERBOSE || process.env.VERBOSE_PARSE_SERVER) {
configureLogger({level: 'silly'});
}

const filesControllerAdapter = loadAdapter(filesAdapter, () => {
return new GridStoreAdapter(databaseURI);
Expand Down
4 changes: 4 additions & 0 deletions src/cli/cli-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,9 @@ export default {
env: "PARSE_SERVER_SESSION_LENGTH",
help: "Session duration, defaults to 1 year",
action: numberParser("sessionLength")
},
"verbose": {
env: "VERBOSE",
help: "Set the logging to verbose"
}
};
8 changes: 0 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import S3Adapter from 'parse-server-s3-adapter'
import FileSystemAdapter from 'parse-server-fs-adapter'
import { useExternal } from './deprecated'

if (process.env.VERBOSE || process.env.VERBOSE_PARSE_SERVER) {
winston.level = 'silly';
}

if (process.env.DEBUG || process.env.DEBUG_PARSE_SERVER) {
winston.level = 'debug';
}

// Factory function
let _ParseServer = function(options) {
let server = new ParseServer(options);
Expand Down
11 changes: 5 additions & 6 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {

let currentLogsFolder = LOGS_FOLDER;

function generateTransports() {
let level = process.env.VERBOSE ? 'verbose': 'info';
function generateTransports(level) {
let transports = [
new (DailyRotateFile)({
filename: 'parse-server.info',
Expand All @@ -38,7 +37,8 @@ function generateTransports() {

const logger = new winston.Logger();

export function configureLogger({logsFolder}) {
export function configureLogger({logsFolder, level = winston.level}) {
winston.level = level;
logsFolder = logsFolder || currentLogsFolder;

if (!path.isAbsolute(logsFolder)) {
Expand All @@ -50,15 +50,14 @@ export function configureLogger({logsFolder}) {
currentLogsFolder = logsFolder;

logger.configure({
transports: generateTransports()
transports: generateTransports(level)
})
}

configureLogger({logsFolder: LOGS_FOLDER});

export function addGroup(groupName) {
let level = process.env.VERBOSE ? 'verbose': 'info';

let level = winston.level;
let transports = generateTransports().concat(new (DailyRotateFile)({
filename: groupName,
dirname: currentLogsFolder,
Expand Down

0 comments on commit f8ebcc9

Please sign in to comment.