Permalink
Browse files

browser

  • Loading branch information...
1 parent 7f6e456 commit 20a535ac1bbd25a7a0b9eff6487592e8f4911580 @lancejpollard committed Oct 22, 2011
Showing with 18 additions and 8 deletions.
  1. +1 −1 README.md
  2. +3 −3 lib/common-logger.js
  3. +1 −1 spec/common_logger_spec.coffee
  4. +10 −0 spec/index.html
  5. +3 −3 src/common-logger.coffee
View
2 README.md
@@ -12,7 +12,7 @@ npm install common-logger
### Node.js
-``` javascript
+``` coffeescript
CommonLogger = require('common-logger')
```
View
6 lib/common-logger.js
@@ -42,11 +42,11 @@
if (options.out) {
this.out = options.out;
}
- this.colorized = options.hasOwnProperty("colorized") ? options.colorized : true;
+ this.colorized = options.hasOwnProperty("colorized") ? options.colorized : false;
this.colors = this.constructor.colors.concat();
}
CommonLogger.prototype.out = function(message) {
- return message;
+ return console.log(message);
};
CommonLogger.prototype.colorize = function() {
var color, colors, i, result, string;
@@ -85,7 +85,7 @@
return this.log(this.constructor.ERROR, arguments);
};
CommonLogger.prototype.warn = function() {
- return this.log(this.constructor.WARNING, arguments);
+ return this.log(this.constructor.WARN, arguments);
};
CommonLogger.prototype.info = function() {
return this.log(this.constructor.INFO, arguments);
View
2 spec/common_logger_spec.coffee
@@ -22,7 +22,7 @@ describe 'common-logger', ->
describe 'format', ->
beforeEach ->
- @logger = new CommonLogger(colorized: false)
+ @logger = new CommonLogger(colorized: false, out: (m) -> m)
it 'should default to a date format', ->
now = new Date().toUTCString()
View
10 spec/index.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='UTF-8' />
+ <script src="../lib/common-logger.js" type="text/javascript"></script>
+ <title>Common Logger Spec</title>
+ </head>
+ <body>
+ </body>
+</html>
View
6 src/common-logger.coffee
@@ -39,10 +39,10 @@ class CommonLogger
@level = options.level || @constructor.DEBUG
@out = options.out if options.out
# set to false if you're in the browser
- @colorized = if options.hasOwnProperty("colorized") then options.colorized else true
+ @colorized = if options.hasOwnProperty("colorized") then options.colorized else false
@colors = @constructor.colors.concat()
- out: (message) -> message
+ out: (message) -> console.log(message)
colorize: ->
colors = Array.prototype.slice.call(arguments)
@@ -74,7 +74,7 @@ class CommonLogger
@log(@constructor.ERROR, arguments)
warn: ->
- @log(@constructor.WARNING, arguments)
+ @log(@constructor.WARN, arguments)
info: ->
@log(@constructor.INFO, arguments)

0 comments on commit 20a535a

Please sign in to comment.