pixl-logger
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -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 @@ |
{ | ||
"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" |
@@ -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: | ||
![Colored Log Example](https://pixlcore.com/software/pixl-logger/colored-log-example.png) | ||
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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20361
259
272
6
+ Addedchalk@^1.1.1
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)