Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #156 #158

Merged
merged 1 commit into from
Sep 9, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,34 @@ function createLogMessage(level, message, logObj) {

if (logObj !== null && logObj !== undefined) {

if (util.isArray(logObj)) {
msg += ' | Array=';
if (logObj.length > 0) {
msg += util.inspect(logObj[0], false, config.inspectDepth);
}
for (var ix = 1; ix < logObj.length; ix++) {
msg += ', ' + util.inspect(logObj[ix], false, config.inspectDepth);
}
for (var i in logObj) {
if(logObj.hasOwnProperty(i)){

} else {
for (var i in logObj) {
//Values printed previously won't be printed again
if (predefinedValues.indexOf(i) === -1) {
msg += ' | ' + i + '=' + util.inspect(logObj[i], false, config.inspectDepth);

msg += ' | ' + i + '=';

if (util.isArray(logObj[i])) {

msg += '[';

//First element
if (logObj[i].length > 0) {
msg += util.inspect(logObj[i][0], false, config.inspectDepth);
}

//Remaining elements
for (var ix = 1; ix < logObj[i].length; ix++) {
msg += ', ' + util.inspect(logObj[i][ix], false, config.inspectDepth);
}

msg += ']';


} else {
msg += util.inspect(logObj[i], false, config.inspectDepth);
}
}
}
}
Expand Down Expand Up @@ -98,10 +113,10 @@ function createWinston(cfg) {
if (err.path === config.File.filename || err.stack.indexOf('/node_modules/winston/') !== -1) {

if (!winstonError) {
//User must be noted that file transport has been removed
//User must be noted that file transport cannot be used anymore
var logType = 'warning';
var logMsg = createLogMessage(logType, 'It\'s not possibe write on log file. File transport has been ' +
'removed. Log messages will be printed on console.', { component: 'logger' });
var logMsg = createLogMessage(logType, 'It\'s not possible write to log file. Log messages won\'t be ' +
'written to log file anymore.', { component: 'logger' });
winstonLogger[logType](logMsg);
}

Expand Down