1.1.6 • Published 5 years ago

neslogging v1.1.6

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 years ago

Installation:

npm install --save @daymon-nes/nes-logging

a wrapper for log4js/node library with custom appenders

Example:

const neslogging = require('neslogging');
//setup only once
neslogger.setup(config:optional);


//default config if nesslogger doesn't detect any custom config;
defaultconfig {
  appenders: {
    console: { "type":"console" },
    kinesis: {
      "type":"kinesis",
      "identityPoolId":"us-east-1:a1a30fa6-dda8-44ba-bfd9-d7ddc7fc8a40",
      "region":"us-east-1",
      "isExtended": true // NOTICE: It is important in case this appender is defined in appenders directory
    }
	},
    // you can specify different categories
	categories: {
		default: { "appenders": [ "console" ], "level": "all" },
        test: { "appenders":["console","kinesis], "level":"error"}
	}
	//geoTracking: toggle ON/OFF geodata
	geoTracking:true
}

//specify categories for neslogger to retrive. If none were given then "default" category will be use
const log = neslogger.getLogger();
//get test logger 
const logTest = neslogger.getLogger('test');


// placeholder doesn't support deeply nested object
logTest.debug("hello my name is $name$. I am $age$ ",{ name:"Huy",age:24,city:"Houston Texas"},attributes:Object);

Result

[2018-11-14T11:08:59.671] [DEBUG] test - hello my name is Huy, I am 24

[2018-11-14T11:08:59.671] [DEBUG] test -
{
	"evenId": "036a7eb0-e7c3-11e8-bb74-cb0abc574bdb",
	"logDate": "Wed Nov 14 2018 11: 08: 59 GMT + 0700(Indochina Time)",
	"geoData": {
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": "10.8142,106.6438"
		},
		"properties": {
			"ipAddress": "113.161.73.14",
			"name": "Ho Chi Minh City",
			"country": "Vietnam"
		}
	},
	"data": null
}

LogLevel:

1/ Debug
2/ Info
3/ Error
appenders (object) - a map of named appenders (string) to appender definitions (object); 
appender definitions must have a property type (string) - other properties depend on the appender type.
categories (object) - a map of named categories (string) to category definitions (object). 

You must define the default category which is used for all log events that do not match a specific category. Category definitions have two properties:
appenders (array of strings) - the list of appender names to be used for this category. A category must have at least one appender.

level (string, case insensitive) - the minimum log level that this category will send to the appenders. For example, if set to ‘error’ then the appenders will only receive log events of level ‘error’, ‘fatal’, ‘mark’ - log events of ‘info’, ‘warn’, ‘debug’, or ‘trace’ will be ignored.

Currently support 2 appenders:

Console

Kinesis comes with these settings

identityPoolId: must have

region: must have

bufferSize: (optional), default = 1000,

flushSize: (optional), default = 100,

flushInterval: (optional), default = 5000, resendLimit: (optional), default = 5

Issues:

For Angular 6:

you need to include

(window as any).global = window;

in polyfill.ts

Doesn't support pm2

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.0.5

5 years ago

1.1.2

5 years ago

0.0.14

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago