Permalink
Browse files

updated README

  • Loading branch information...
1 parent 33a0962 commit 9d3e27382ca2875c70705af94177b300a85abae8 @tristanls committed Aug 23, 2012
Showing with 79 additions and 35 deletions.
  1. +79 −35 README.md
View
114 README.md
@@ -3,50 +3,94 @@ logly
`logly` is a small logging framework in the `nodejs` ecosystem that also allows one to set `debug` or `verbose` logging modes.
It is useful to replace comments that describe what the code is doing, especially in `debug` mode.
-Usage
-----
- var logly = require( 'logly' );
+## Usage
+
+```javascript
+var logly = require( 'logly' );
- logly.name( 'myapp' );
- logly.mode( 'debug' );
+logly.name( 'myapp' );
+logly.mode( 'debug' );
- logly.debug( 'debug log' );
- // stdout: myapp[debug]: debug log
+logly.debug( 'debug log' );
+// stdout: myapp[debug]: debug log
- logly.verbose( 'verbose log' );
- // stdout: myapp[verbose]: verbose log
+logly.verbose( 'verbose log' );
+// stdout: myapp[verbose]: verbose log
- logly.log( 'standard log' );
- // stdout: myapp: standard log
+logly.log( 'standard log' );
+// stdout: myapp: standard log
- logly.warn( 'warning log' );
- // stderr: myapp[warn]: warning log
+logly.warn( 'warning log' );
+// stderr: myapp[warn]: warning log
- logly.error( 'error log' );
- // stderr: myapp[error]: error log
-
- logly.stdout( 'stdout log' );
- // stdout: stdout log
- // *above does not include 'myapp'
-
- logly.stderr( 'stderr log' );
- // stderr: stderr log
- // *above does not include 'myapp'
-
-If you want color then you can enable it (by default color is disabled):
+logly.error( 'error log' );
+// stderr: myapp[error]: error log
+
+logly.stdout( 'stdout log' );
+// stdout: stdout log
+// *above does not include 'myapp'
- logly.color(true);
+logly.stderr( 'stderr log' );
+// stderr: stderr log
+// *above does not include 'myapp'
+```
+
+### functions as input
`logly` also accepts functions as input; this is primarily to conditionally produce a debug output of complex something if in `debug` mode, for example:
- var options = { debug: true, output: "some.file" }
- // dump options in debug mode
- logly.debug( function() {
- for ( var i = 0; i < options.length; i++ ) {
- logly.debug( '[OPTION] ' + option + ": " + options[ option ] );
- }
- });
- // stdout: myapp[debug]: [OPTION] debug: true
- // stdout: myapp[debug]: [OPTION] output: some.file
+```javascript
+var options = { debug: true, output: "some.file" }
+// dump options in debug mode
+logly.debug( function() {
+ for ( var i = 0; i < options.length; i++ ) {
+ logly.debug( '[OPTION] ' + option + ": " + options[ option ] );
+ }
+});
+// stdout: myapp[debug]: [OPTION] debug: true
+// stdout: myapp[debug]: [OPTION] output: some.file
+```
+
+## Options
+
+### color/colour
+
+If you want color then you can enable it (by default color is disabled):
+
+```javascript
+logly.options( { color : true } );
+```
+
+You can also use `color` or `colour` functions (maintained for backward compatibility):
+
+```javascript
+logly.color(true);
+logly.colour(true);
+```
+
+### date
+
+You can include a date prefix as well:
+
+```javascript
+logly.options( { date : true } );
+logly.log( 'with date' );
+// stdout: Wed Aug 22 2012 21:22:52 GMT-0500 (CDT) myapp: with date
+```
+
+[ISO8601](http://en.wikipedia.org/wiki/ISO_8601) format is also available:
+
+```javascript
+logly.options( { date : 'iso' } ); // or 'ISO8601', 'iso8601', 'ISO'
+logly.log( 'with iso date' );
+// stdout: 2012-08-23T02:26:14.841Z myapp: with iso date
+```
+
+### `options` object
+
+You can pass in the above options all together:
+```javascript
+logly.options( { colour : true, date : 'iso' } );
+```

0 comments on commit 9d3e273

Please sign in to comment.