Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

io-ng2-logger

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ng2-logger - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

34

lib/logger.d.ts

@@ -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;

2

package.json
{
"name": "io-ng2-logger",
"version": "0.1.1",
"version": "0.1.2",
"description": "Angular2 Base Utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc