pixl-logger
Advanced tools
Comparing version 1.0.12 to 1.0.13
// Generic Logger Class for Node.JS | ||
// Copyright (c) 2012 - 2017 Joseph Huckaby and PixlCore.com | ||
// Copyright (c) 2012 - 2018 Joseph Huckaby and PixlCore.com | ||
// Released under the MIT License | ||
@@ -73,9 +73,10 @@ | ||
// import args into object | ||
for (var key in args) this.args[key] = args[key]; | ||
// for (var key in dargs) this.args[key] = dargs[key]; | ||
for (var key in this.args) { | ||
if (!(key in args)) args[key] = this.args[key]; | ||
} | ||
// set automatic column values | ||
this.args.hires_epoch = now.getTime() / 1000; | ||
this.args.epoch = Math.floor( this.args.hires_epoch ); | ||
this.args.date = dargs.yyyy_mm_dd.replace(/\//g, '-') + ' ' + dargs.hh_mi_ss; | ||
args.hires_epoch = now.getTime() / 1000; | ||
args.epoch = Math.floor( args.hires_epoch ); | ||
args.date = dargs.yyyy_mm_dd.replace(/\//g, '-') + ' ' + dargs.hh_mi_ss; | ||
@@ -86,3 +87,3 @@ // populate columns | ||
var col = this.columns[idx]; | ||
var val = this.args[col]; | ||
var val = args[col]; | ||
@@ -101,3 +102,3 @@ if ((typeof(val) == 'undefined') || (val === null) || !val.toString) val = ''; | ||
// compose log row | ||
var line = this.serializer ? this.serializer(cols, this.args) : ('[' + cols.join('][') + "]\n"); | ||
var line = this.serializer ? this.serializer(cols, args) : ('[' + cols.join('][') + "]\n"); | ||
this.lastRow = line; | ||
@@ -108,24 +109,24 @@ | ||
if (this.pather) { | ||
path = this.pather( path, this.args ); | ||
path = this.pather( path, args ); | ||
} | ||
else if (path.indexOf('[') > -1) { | ||
path = Tools.substitute( path, this.args ); | ||
path = Tools.substitute( path, args ); | ||
} | ||
// append to log | ||
if (this.args.sync) fs.appendFileSync(path, line); | ||
if (args.sync) fs.appendFileSync(path, line); | ||
else fs.appendFile(path, line, function() {}); | ||
// echo to console if desired | ||
if (this.args.echo) { | ||
if (args.echo) { | ||
if (this.echoer) { | ||
if (typeof(this.echoer) == 'function') { | ||
this.echoer( line, cols, this.args ); | ||
this.echoer( line, cols, args ); | ||
} | ||
else if (typeof(this.echoer) == 'string') { | ||
if (this.args.sync) fs.appendFileSync(this.echoer, line); | ||
if (args.sync) fs.appendFileSync(this.echoer, line); | ||
else fs.appendFile(this.echoer, line, function() {}); | ||
} | ||
} | ||
else if (this.args.color) { | ||
else if (args.color) { | ||
var ccols = []; | ||
@@ -148,3 +149,3 @@ var nclrs = this.columnColors.length; | ||
// emit row as an event | ||
this.emit( 'row', line, cols, this.args ); | ||
this.emit( 'row', line, cols, args ); | ||
}, | ||
@@ -151,0 +152,0 @@ |
{ | ||
"name": "pixl-logger", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "A simple logging class which generates [bracket][delimited] log columns.", | ||
@@ -21,6 +21,6 @@ "author": "Joseph Huckaby <jhuckaby@gmail.com>", | ||
"dependencies": { | ||
"async": "^1.0.0", | ||
"mkdirp": "^0.5.1 || ^1.0.0", | ||
"glob": "^5.0.0", | ||
"chalk": "^1.1.1", | ||
"async": "2.6.0", | ||
"mkdirp": "0.5.1", | ||
"glob": "5.0.15", | ||
"chalk": "2.4.1", | ||
"pixl-class": "^1.0.0", | ||
@@ -27,0 +27,0 @@ "pixl-tools": "^1.0.0" |
@@ -54,2 +54,4 @@ # Overview | ||
Note that when you pass arguments to `print()` they are not saved for subsequent calls. They are only used for that one log row. You need to call `set()` to make them stick. | ||
You can also fetch arg values using `get()`. Pass in a key to fetch one arg, or omit to get the entire `args` object back. | ||
@@ -332,3 +334,3 @@ | ||
Copyright (c) 2015 - 2017 Joseph Huckaby | ||
Copyright (c) 2015 - 2018 Joseph Huckaby | ||
@@ -335,0 +337,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
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
26365
287
352
3
+ Addedansi-styles@3.2.1(transitive)
+ Addedasync@2.6.0(transitive)
+ Addedchalk@2.4.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.5.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedasync@1.5.2(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedasync@2.6.0
Updatedchalk@2.4.1
Updatedglob@5.0.15
Updatedmkdirp@0.5.1