pixl-logger
Advanced tools
+21
-1
@@ -12,2 +12,3 @@ // Generic Logger Class for Node.JS | ||
| var glob = require('glob'); | ||
| var chalk = require('chalk'); | ||
@@ -19,2 +20,5 @@ var Class = require("pixl-class"); | ||
| columnColors: ['gray', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan'], | ||
| dividerColor: 'dim', | ||
| __construct: function(path, columns, args) { | ||
@@ -95,3 +99,19 @@ // create new logger instance | ||
| // echo to console if desired | ||
| if (this.args.echo) process.stdout.write(line); | ||
| if (this.args.echo) { | ||
| if (this.args.color) { | ||
| var ccols = []; | ||
| var nclrs = this.columnColors.length; | ||
| var dclr = chalk[ this.dividerColor ]; | ||
| for (var idx = 0, len = cols.length; idx < len; idx++) { | ||
| ccols.push( chalk[ this.columnColors[idx % nclrs] ]( cols[idx] ) ); | ||
| } | ||
| process.stdout.write( | ||
| dclr('[') + ccols.join( dclr('][') ) + dclr(']') + "\n" | ||
| ); | ||
| } // color | ||
| else { | ||
| process.stdout.write(line); | ||
| } | ||
| } | ||
| }, | ||
@@ -98,0 +118,0 @@ |
+2
-1
| { | ||
| "name": "pixl-logger", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "A simple logging class which generates [bracket][delimited] log columns.", | ||
@@ -24,2 +24,3 @@ "author": "Joseph Huckaby <jhuckaby@gmail.com>", | ||
| "glob": "^5.0.0", | ||
| "chalk": "^1.1.1", | ||
| "pixl-class": ">=1.0.0", | ||
@@ -26,0 +27,0 @@ "pixl-tools": ">=1.0.0" |
+16
-0
@@ -141,2 +141,18 @@ # Overview | ||
| ### Colored Logs | ||
| If you set the `color` arg to any true value, the logger will echo all log entries in color (assuming you have a terminal that supports color), using the [chalk](https://www.npmjs.com/package/chalk) module. The color sequence is `gray`, `red`, `green`, `yellow`, `blue`, `magenta` and `cyan`. If your log has more than 7 columns, the colors repeat. The bracket dividers are printed in `dim`. Here is a screenshot: | ||
|  | ||
| Example: | ||
| ```javascript | ||
| logger.set( 'echo', true ); | ||
| logger.set( 'color', true ); | ||
| logger.debug( 1, "This will be colored in the console!" ); | ||
| ``` | ||
| Note that the color only affects the local echo in your terminal. The log file itself is still written in plain text. | ||
| ## Last Line Logged | ||
@@ -143,0 +159,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
20361
7.16%259
7.47%272
6.25%6
20%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added