Permalink
Browse files

[minor api] Expose `cliff.logger` for upstream integration

  • Loading branch information...
1 parent a7dac3a commit 42b615a6985f525ec8c13eebb2673af0d1d686f8 @indexzero indexzero committed Feb 8, 2012
Showing with 29 additions and 9 deletions.
  1. +29 −9 lib/cliff.js
View
@@ -9,14 +9,34 @@ var colors = require('colors'),
eyes = require('eyes'),
winston = require('winston');
-var cliff = exports;
+var cliff = exports,
+ logger;
+
+cliff.__defineGetter__('logger', function () {
+ return logger;
+});
+
+cliff.__defineSetter__('logger', function (val) {
+ logger = val;
+
+ //
+ // Setup winston to use the `cli` formats
+ //
+ if (logger.cli) {
+ logger.cli();
+ }
+});
//
-// Setup winston to use the `cli` formats
+// Set the default logger for cliff.
//
-winston.cli();
+cliff.logger = new winston.Logger();
-cliff.inspect = eyes.inspector({ stream: null,
+//
+// Expose a default `eyes` inspector.
+//
+cliff.inspector = eyes.inspector;
+cliff.inspect = eyes.inspector({ stream: null,
styles: { // Styles applied to stdout
all: null, // Overall style applied to everything
label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
@@ -221,7 +241,7 @@ cliff.stringifyLiteral = function stringifyLiteral (literal) {
}
};
-cliff.typeOf = function typeOf (value) {
+cliff.typeOf = function typeOf(value) {
var s = typeof(value),
types = [Object, Array, String, RegExp, Number, Function, Boolean, Date];
@@ -240,11 +260,11 @@ cliff.typeOf = function typeOf (value) {
return s;
};
-var realLength = function (str) {
+function realLength(str) {
return ("" + str).replace(/\u001b\[\d+m/g,'').length;
-};
+}
-var longestElement = function (a) {
+function longestElement(a) {
var l = 0;
for (var i = 0; i < a.length; i++) {
var new_l = realLength(a[i]);
@@ -254,4 +274,4 @@ var longestElement = function (a) {
}
return l;
-};
+}

0 comments on commit 42b615a

Please sign in to comment.