io-ng2-logger
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,32 @@ | ||
export declare function log(log: any): void; | ||
export declare function endPoint(app: any): void; | ||
/** | ||
* the base value interface | ||
* | ||
* @export | ||
* @interface IMeta | ||
*/ | ||
export interface IMeta { | ||
application: string; | ||
category?: string; | ||
comment?: string; | ||
created: number; | ||
endpoint: string; | ||
environment: string; | ||
event: string; | ||
type?: string; | ||
user?: string; | ||
} | ||
/** | ||
* | ||
* | ||
* @export - available in the modules as a function eg .. logger.log | ||
* @param {*} log - the log object | ||
* @returns {void} - doesn't return anything | ||
*/ | ||
export declare function log(log: any, cb: any): any; | ||
/** | ||
* both meta and config must have the same values | ||
* | ||
* @export - to be used in the modules | ||
* @param {*} val - boject with some base settings | ||
*/ | ||
export declare function config(val: any): void; |
'use strict'; | ||
var request = require("request"); | ||
/** | ||
* assign the meta data | ||
*/ | ||
var meta = { | ||
endpoint: undefined, | ||
log: undefined, | ||
application: undefined | ||
user: null, | ||
application: process.env.APP || null, | ||
category: null, | ||
comment: null, | ||
created: null, | ||
endpoint: 'https://io-ws-logger.w3ibm.mybluemix.net/api', | ||
environment: process.env.NODE_ENV || null, | ||
event: null, | ||
type: null, | ||
}; | ||
function log(log) { | ||
/** the meta data object to be posted */ | ||
var logMeta = {}; | ||
/** | ||
* the function to set the meta | ||
* data come in and will be verified against the meta boject | ||
* and the logMeta data will be constructed, that object wil be sent | ||
* | ||
* @param {*} val | ||
*/ | ||
function setMeta(val) { | ||
logMeta = {}; | ||
for (var key in meta) { | ||
if (meta.hasOwnProperty(key)) { | ||
logMeta[key] = val[key] || meta[key] || null; | ||
} | ||
} | ||
} | ||
/** | ||
* | ||
* | ||
* @export - available in the modules as a function eg .. logger.log | ||
* @param {*} log - the log object | ||
* @returns {void} - doesn't return anything | ||
*/ | ||
function log(log, cb) { | ||
if (meta.environment === null || meta.application === null) { | ||
return; | ||
} | ||
setMeta(log); | ||
meta.created = new Date().getTime(); | ||
delete logMeta.endpoint; | ||
var options = { | ||
@@ -16,3 +55,3 @@ body: { | ||
}, | ||
log: log, | ||
log: logMeta, | ||
}, | ||
@@ -26,14 +65,26 @@ json: true, | ||
console.info(err); | ||
return (err); | ||
if (cb) { | ||
cb(err); | ||
} | ||
} | ||
console.info(body); | ||
if (cb) { | ||
cb(false, body); | ||
} | ||
}); | ||
} | ||
exports.log = log; | ||
function endPoint(app) { | ||
meta.application = app.application; | ||
meta.endpoint = app.endpoint; | ||
/** | ||
* both meta and config must have the same values | ||
* | ||
* @export - to be used in the modules | ||
* @param {*} val - boject with some base settings | ||
*/ | ||
function config(val) { | ||
for (var key in meta) { | ||
if (meta.hasOwnProperty(key) && val.hasOwnProperty(key)) { | ||
meta[key] = val[key]; | ||
} | ||
} | ||
setMeta(val); | ||
} | ||
exports.endPoint = endPoint; | ||
// module.exports = Logger; | ||
// module.exports = Logger; | ||
exports.config = config; |
{ | ||
"name": "io-ng2-logger", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Angular2 Base Utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
7314
250
2