hologger-streamer
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,2 +0,2 @@ | ||
var _ = require('lodash'); | ||
var isNumber = require('lodash.isnumber'); | ||
@@ -31,8 +31,7 @@ | ||
} | ||
const LIBRARY_CODE = (_.isNumber(isil))? isil*10000 : null; | ||
const EVENT_CODE = (_.isNumber(isbn))? isbn : null; | ||
const FULL_CODE = (!LIBRARY_CODE || !EVENT_CODE)? | ||
"UNCOMPOSABLE CODE" | ||
const LIBRARY_CODE = (isNumber(isil))? isil*10000 : null; | ||
const EVENT_CODE = (isNumber(isbn))? isbn : null; | ||
const FULL_CODE = (!LIBRARY_CODE || !EVENT_CODE)? "UNCOMPOSABLE CODE" | ||
: SEVERITY_CODE + LIBRARY_CODE + EVENT_CODE; | ||
return FULL_CODE; | ||
}; |
@@ -18,5 +18,4 @@ var sanitize = require("./sanitize"); | ||
return function composeAndLog(library, isil, ...args){ | ||
const STREAMER = this; | ||
const RIFS = STREAMER._requestInstanceFieldsSubset; | ||
const RBFS = STREAMER._requestBodyFieldsSubset; | ||
const RIFS = this._requestInstanceFieldsSubset; | ||
const RBFS = this._requestBodyFieldsSubset; | ||
@@ -27,4 +26,4 @@ sanitize(args); | ||
const CODE = STREAMER._composeCode(level, isil, ISBN); | ||
const MESSAGE = STREAMER._composeMessage(level, library, ISBN, INFO); | ||
const CODE = this._composeCode(level, isil, ISBN); | ||
const MESSAGE = this._composeMessage(level, library, ISBN, INFO); | ||
const SLUG = "[" + CODE + "] [" + MESSAGE + "]"; | ||
@@ -40,4 +39,5 @@ | ||
STREAMER._log(STREAMER["_"+level+"Drain"], INFO); | ||
var outlet = this["_"+level+"Drain"]; | ||
this._log(outlet, INFO); | ||
}; | ||
}; |
/** | ||
* @description | ||
* Puesto que en entornos de desarrollo (development) solo se loguea un | ||
* mensaje que resume el evento (al contrario que en pre-produccion y en | ||
* produccion, donde se almacena como JSON toda la informacion del mismo), | ||
* en los casos en que el evento contenga un Object de tipo Error, ademas | ||
* del slug se loguea explicitamente el stack del Error, pues de otro modo se | ||
* pierde la informacion contenida en el mismo, vital para la depuracion | ||
* del mismo. | ||
* | ||
@@ -17,11 +10,7 @@ * | ||
* `console` (`console.log`). Required. | ||
* @param {Mixed} info: | ||
* @param {Mixed} info | ||
*/ | ||
exports = module.exports = function(outlet, info){ | ||
if (info && info.slug) outlet(info.slug); | ||
if (info && info.err) { | ||
outlet("====================ERR STACK BEGINS==================="); | ||
outlet(info.err.stack); | ||
outlet("====================ERR STACK ENDS==================="); | ||
} | ||
if (this._logLevels.indexOf(info.severity) < this._minLogLevel) return; | ||
else console.warn("[HOLOGGER] Log failed. Streamer "+this.name+" does not implement _log method."); | ||
}; |
@@ -1,2 +0,7 @@ | ||
var _ = require('lodash'); | ||
var isBoolean = require('lodash.isboolean'); | ||
var isString = require('lodash.isstring'); | ||
var isNumber = require('lodash.isnumber'); | ||
var isError = require('lodash.iserror'); | ||
var isPlainObject = require('lodash.isplainobject'); | ||
var clone = require('lodash.clone'); | ||
@@ -7,4 +12,4 @@ | ||
* Modifica, en su caso, los parametros de entrada de manera que a su conclusion | ||
* info se halle siempre convertido (estandarizado) en un Object que recoge en | ||
* forma de propiedades la info original presentada a saneamiento. | ||
* `info` se halle siempre convertido (estandarizado) en un {Object} que recoge | ||
* en forma de propiedades la info original presentada a saneamiento. | ||
* Ademas de esta estandarizacion del tipo de primitiva, se produce una estandarizacion | ||
@@ -16,3 +21,3 @@ * secundaria en el nombre de un numero contado de propiedades, siendo estas: | ||
* Para info de tipo atomico (Boolean, String, Number) se almacena la informacion | ||
* original en la propiedad `str`. Si la info es un Error, se almacena en la | ||
* original en la propiedad `str`. Si la info es un {Error}, se almacena en la | ||
* propiedad `err`. | ||
@@ -30,3 +35,3 @@ * | ||
exports = module.exports = function(args){ | ||
/////// ARGUMENTS | ||
//// ARGUMENTS | ||
//logger() | ||
@@ -36,6 +41,6 @@ if (args.length === 0) { | ||
args[1] = {}; | ||
//logger({foo: "bar"}) || logger(3) | ||
} else if (args.length ==1) { | ||
//logger(3) | ||
if (_.isNumber(args[0])){ | ||
if (isNumber(args[0])){ | ||
args[0] = args[0]; | ||
@@ -47,3 +52,3 @@ args[1] = {}; | ||
} else { | ||
args[1] = _.clone(args[0]); | ||
args[1] = clone(args[0]); | ||
args[0] = null; | ||
@@ -54,19 +59,21 @@ } | ||
/////// INFO | ||
if (_.isString(args[1])) args[1] = {str: args[1]}; | ||
else if (_.isNumber(args[1])) args[1] = {str: args[1].toString()}; | ||
else if (_.isBoolean(args[1])) args[1] = {str: args[1].toString()}; | ||
else if (_.isError(args[1])) args[1] = {err: args[1]}; | ||
else if (_.isPlainObject(args[1])) args[1] = args[1]; | ||
//// INFO | ||
if (isString(args[1])) args[1] = {str: args[1]}; | ||
else if (isNumber(args[1])) args[1] = {str: args[1].toString()}; | ||
else if (isBoolean(args[1])) args[1] = {str: args[1].toString()}; | ||
else if (isError(args[1])) args[1] = {err: args[1]}; | ||
else if (isPlainObject(args[1])) args[1] = args[1]; | ||
else args[1] = {}; | ||
/////// RENOMBRAMIENTO | ||
//// RENOMBRAMIENTO | ||
if (args[1].error) { | ||
args[1].err = _.clone(args[1].error); | ||
args[1].err = clone(args[1].error); | ||
delete args[1].error; | ||
} | ||
if (args[1].request) { | ||
args[1].req = _.clone(args[1].request); | ||
args[1].req = clone(args[1].request); | ||
delete args[1].request; | ||
} | ||
}; |
@@ -1,2 +0,2 @@ | ||
var _ = require('lodash'); | ||
var unset = require('lodash.unset'); | ||
@@ -7,3 +7,3 @@ | ||
* Selecciona y devuelve un subconjunto de propiedades de la solicitud pasada como | ||
* argumento, excluyendo de mismo, en caso de que una de tales fuera 'body', las | ||
* argumento, excluyendo del mismo, en caso de que una de tales fuera `body`, las | ||
* propiedades de este igualmente explicitadas. | ||
@@ -31,3 +31,3 @@ * | ||
REQUEST.body = req.body; | ||
rbfs.forEach( (field)=>{_.unset(REQUEST, 'body.'+field)} ); | ||
rbfs.forEach( (field)=>{unset(REQUEST, 'body.'+field)} ); | ||
} | ||
@@ -34,0 +34,0 @@ |
@@ -18,11 +18,4 @@ var handlerFactory = require("./handler-factory"); | ||
this._requestBodyFieldsSubset = (rbfs)? rbfs.split(",") : []; | ||
this._debugDrain; //a implementar por clases que hereden de {Streamer} | ||
this._infoDrain; //idem | ||
this._noticeDrain; //idem | ||
this._warningDrain; //idem | ||
this._errorDrain; //idem | ||
this._criticalDrain; //idem | ||
this._alertDrain; //idem | ||
this._emergencyDrain; //idem | ||
this._logLevels = ["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]; | ||
this._minLogLevel = process.env.HOLOGGER_LOG_LEVEL || 0; | ||
} | ||
@@ -39,2 +32,3 @@ | ||
Streamer.prototype.debug = handlerFactory("debug"); | ||
Streamer.prototype._debugDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -50,2 +44,3 @@ | ||
Streamer.prototype.info = handlerFactory("info"); | ||
Streamer.prototype._infoDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -61,2 +56,3 @@ | ||
Streamer.prototype.notice = handlerFactory("notice"); | ||
Streamer.prototype._noticeDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -72,2 +68,3 @@ | ||
Streamer.prototype.warning = handlerFactory("warning"); | ||
Streamer.prototype._warningDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -83,2 +80,3 @@ | ||
Streamer.prototype.error = handlerFactory("error"); | ||
Streamer.prototype._errorDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -94,2 +92,3 @@ | ||
Streamer.prototype.critical = handlerFactory("critical"); | ||
Streamer.prototype._criticalDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -105,2 +104,3 @@ | ||
Streamer.prototype.alert = handlerFactory("alert"); | ||
Streamer.prototype._alertDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -116,2 +116,3 @@ | ||
Streamer.prototype.emergency = handlerFactory("emergency"); | ||
Streamer.prototype._emergencyDrain; //a implementar por clases que hereden de {Streamer} | ||
@@ -118,0 +119,0 @@ |
{ | ||
"name": "hologger-streamer", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Base Class implementing Streamer API for Hologger", | ||
@@ -18,3 +18,9 @@ "main": "index.js", | ||
"handlebars": "^4.0.10", | ||
"lodash": "^4.17.4" | ||
"lodash.clone": "^4.5.0", | ||
"lodash.isboolean": "^3.0.3", | ||
"lodash.iserror": "^3.1.1", | ||
"lodash.isnumber": "^3.0.3", | ||
"lodash.isplainobject": "^4.0.6", | ||
"lodash.isstring": "^4.0.1", | ||
"lodash.unset": "^4.5.2" | ||
}, | ||
@@ -21,0 +27,0 @@ "devDependencies": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
14096
8
296
3
+ Addedlodash.clone@^4.5.0
+ Addedlodash.isboolean@^3.0.3
+ Addedlodash.iserror@^3.1.1
+ Addedlodash.isnumber@^3.0.3
+ Addedlodash.isplainobject@^4.0.6
+ Addedlodash.isstring@^4.0.1
+ Addedlodash.unset@^4.5.2
+ Addedlodash.clone@4.5.0(transitive)
+ Addedlodash.isboolean@3.0.3(transitive)
+ Addedlodash.iserror@3.1.1(transitive)
+ Addedlodash.isnumber@3.0.3(transitive)
+ Addedlodash.isplainobject@4.0.6(transitive)
+ Addedlodash.isstring@4.0.1(transitive)
+ Addedlodash.unset@4.5.2(transitive)
- Removedlodash@^4.17.4
- Removedlodash@4.17.21(transitive)