more jsstyle'ing

This commit is contained in:
Trent Mick 2012-04-27 17:31:46 -07:00
parent 11b91cadd4
commit 1a916f6ad7

View file

@ -51,7 +51,7 @@ if (!format) {
var inspect = util.inspect;
var formatRegExp = /%[sdj%]/g;
format = function format(f) {
if (typeof f !== 'string') {
if (typeof (f) !== 'string') {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(inspect(arguments[i]));
@ -75,7 +75,7 @@ if (!format) {
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (x === null || typeof x !== 'object') {
if (x === null || typeof (x) !== 'object') {
str += ' ' + x;
} else {
str += ' ' + inspect(x);
@ -228,13 +228,14 @@ function Logger(options, _childOptions, _childSimple) {
}
}
if ((options.stream || options.level) && options.streams) {
throw new TypeError('cannot mix "streams" with "stream" or "level" options');
throw new TypeError(
'cannot mix "streams" with "stream" or "level" options');
}
if (options.streams && !Array.isArray(options.streams)) {
throw new TypeError('invalid options.streams: must be an array')
}
if (options.serializers && (typeof (options.serializers) !== 'object'
|| Array.isArray(options.serializers))) {
if (options.serializers && (typeof (options.serializers) !== 'object' ||
Array.isArray(options.serializers))) {
throw new TypeError('invalid options.serializers: must be an object')
}
@ -427,27 +428,29 @@ Logger.prototype.child = function (options, simple) {
}
///**
// * Close this logger.
// *
// * This closes streams (that it owns, as per 'endOnClose' attributes on
// * streams), etc. Typically you **don't** need to bother calling this.
// */
//Logger.prototype.close = function () {
// if (this._closed) {
// return;
// }
// if (!this._isSimpleChild) {
// self.streams.forEach(function (s) {
// if (s.endOnClose) {
// xxx('closing stream s:', s);
// s.stream.end();
// s.endOnClose = false;
// }
// });
// }
// this._closed = true;
//}
/* BEGIN JSSTYLED */
/**
* Close this logger.
*
* This closes streams (that it owns, as per 'endOnClose' attributes on
* streams), etc. Typically you **don't** need to bother calling this.
Logger.prototype.close = function () {
if (this._closed) {
return;
}
if (!this._isSimpleChild) {
self.streams.forEach(function (s) {
if (s.endOnClose) {
xxx('closing stream s:', s);
s.stream.end();
s.endOnClose = false;
}
});
}
this._closed = true;
}
*/
/* END JSSTYLED */
/**
@ -495,7 +498,7 @@ Logger.prototype.level = function level(value) {
* log = new Logger({
* streams: [
* {
* name: 'foo', // <--- proposed new option, yucky controlling uniqueness
* name: 'foo',
* path: '/var/log/my-service/foo.log'
* level: 'trace'
* },
@ -509,10 +512,11 @@ Logger.prototype.level = function level(value) {
Logger.prototype.levels = function levels(name, value) {
if (name === undefined) {
assert.equal(value, undefined);
return this.streams.map(function (s) { return s.level });
return this.streams.map(
function (s) { return s.level });
}
var stream;
if (typeof name === 'number') {
if (typeof (name) === 'number') {
stream = this.streams[name];
if (stream === undefined) {
throw new Error('invalid stream index: ' + name);
@ -686,7 +690,7 @@ Logger.prototype.trace = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.trace(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.trace(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.trace(fields, msg, ...)`
@ -725,7 +729,7 @@ Logger.prototype.debug = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.debug(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.debug(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.debug(fields, msg, ...)`
@ -764,7 +768,7 @@ Logger.prototype.info = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.info(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.info(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.info(fields, msg, ...)`
@ -803,7 +807,7 @@ Logger.prototype.warn = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.warn(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.warn(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.warn(fields, msg, ...)`
@ -842,7 +846,7 @@ Logger.prototype.error = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.error(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.error(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.error(fields, msg, ...)`
@ -881,7 +885,7 @@ Logger.prototype.fatal = function () {
} else {
msgArgs = Array.prototype.slice.call(arguments, 1);
}
} else if (typeof arguments[0] === 'string') { // `log.fatal(msg, ...)`
} else if (typeof (arguments[0]) === 'string') { // `log.fatal(msg, ...)`
fields = null;
msgArgs = Array.prototype.slice.call(arguments);
} else { // `log.fatal(fields, msg, ...)`