Closed TanmoySG closed 2 years ago
Using this Guide - https://www.digitalocean.com/community/tutorials/how-to-create-a-node-js-module
For Coloring the terminal logs using - https://www.npmjs.com/package/chalk
Some guide on Classes in JS - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
"git - How to use actions/checkout@master to get sources into specified folder? - Stack Overflow" https://stackoverflow.com/questions/57914734/how-to-use-actions-checkoutmaster-to-get-sources-into-specified-folder
Can use this to checkout only the helper library and Publish it as a GH Package.
Login to npm
npm adduser
A prompt comes up, fill the details.
npm publish
Voila!
[Publishing to GH Registry] https://gist.github.com/silentHoo/8402d470ef48ef8979b8ecd3e5f206e3
Published to GH Registry - has some issues if I try to install it locally
Needs to set proxy and all that. Which is an added step just to get the package.
Using string-template
for Templating. Link
Installing string-template
npm i string-template
Defining Templates can be done by putting the variable/placeholder name within { }
const template = "{level} : {log}"
Formatting the templates
import format from 'string-template';
const template = "[{level}] {body}"
log() {
const logStatement = format(
template,
{
level:"test",
body: "testval"
}
)
return logLevels.INFO(logStatement);
}
Refer to these examples
"Doing a cleanup action just before Node.js exits - Stack Overflow" https://stackoverflow.com/questions/14031763/doing-a-cleanup-action-just-before-node-js-exits
Save logs in file on exit only. Read Logs and write logs to Program Variables and not to file.
This is the minimum config the user needs to set for monitor, rest is handled by the lib. if not provided.
{
MONITOR: {
port: "8080",
server: "localhost",
publisher: {
publisher: "test"
},
context: {
context: "testcon"
}
}
}
}
While publishing log
const EndpointConfigurations = {
Publisher: {
method : "POST",
header : "GET"
},
Context : {
new: "POST",
existing : "GET"
},
Log: {
new: "POST"
}
}
Published!!!
NodeJS Helper Library/Class for logsmith monitor. May publish a JS counterpart of logsmith - logsmithJS, as a logging library with support for monitor.
[Checkpoints]
[Additional Details]
listeners
are Address/Logsmith Monitor instances that listens to the logs