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

lognext

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lognext - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "lognext",
"version": "0.0.3",
"version": "0.0.4",
"description": "The logger nobody asked for",

@@ -5,0 +5,0 @@ "main": "src/logger.js",

# lognext
The logger nobody asked for
# Installation
```shell
npm install lognext
```
# Usage
## Getting Started
Require the module and instantiate an instance. The topic name is used when tracing messages to help identify their source.
```JavaScript
const Lognext = require('lognext');
const log = new Lognext('topic-name');
```
## Learn by example!
### Standard stuff
```JavaScript
log.writeBox('Standard trace messages');
log.error('This is an error');
log.warn('You have been warned');
log.info('This is informational');
log.verbose('This message is really a lot more information than you probably wanted');
log.debug('This message is for debugging');
log.silly('Tee hee hee!');
```
![img](https://raw.githubusercontent.com/PrinceNebulon/lognext/master/images/standard-trace-messages.png)
### Objects can be traced out too!
```JavaScript
log.writeBox('Tracing with objects');
log.error(new Error('This is an error'));
let data = { prop1: 'val1', prop2: ['a', 'b', 'c']};
log.info('Data: ', data);
log.debug('Data: ', data);
```
![img](https://raw.githubusercontent.com/PrinceNebulon/lognext/master/images/tracing-with-objects.png)
### Color can be turned off for output windows that don't support ANSI colors.
```JavaScript
log.setUseColor(false);
log.error('This is an error');
log.warn('You have been warned');
log.info('This is informational');
log.verbose('This message is really a lot more information than you probably wanted');
log.debug('This message is for debugging');
log.silly('Tee hee hee!');
```
![img](https://raw.githubusercontent.com/PrinceNebulon/lognext/master/images/no-color.png)
### Trace levels can be controlled to disable traces above the set level.
```JavaScript
log.writeBox('Log Level Examples');
['error', 'warn', 'info', 'verbose', 'debug', 'silly'].forEach((level) => {
console.log(`+++ Log level => ${level}`);
log.setLogLevel(level);
log.error('This is an error');
log.warn('You have been warned');
log.info('This is informational');
log.verbose('This message is really a lot more information than you probably wanted');
log.debug('This message is for debugging');
log.silly('Tee hee hee!');
});
```
![img](https://raw.githubusercontent.com/PrinceNebulon/lognext/master/images/log-levels.png)
### Profile a string to measure time!
```JavaScript
log.profile('foo');
log.writeBox('Let\'s profile!');
setTimeout(()=>{log.profile('foo');}, 100);
```
![img](https://raw.githubusercontent.com/PrinceNebulon/lognext/master/images/profiling.png)

@@ -15,15 +15,15 @@ const _ = require('lodash');

this.log = new Winston.Logger({
transports: [
new Winston.transports.Console({
level: level,
handleExceptions: true,
json: false,
colorize: true
})
],
filters: [
function(level, msg, meta) {
return `${self.topic}${msg}`;
}
]
transports: [
new Winston.transports.Console({
level: level,
handleExceptions: true,
json: false,
colorize: true
})
],
filters: [
function(level, msg) {
return `${self.topic}${msg}`;
}
]
});

@@ -81,3 +81,3 @@ }

var c = 0;
_.forEach(words, function(word, index) {
_.forEach(words, function(word) {
if (!rows[c]) rows[c] = '';

@@ -92,4 +92,4 @@ if (rows[c].length + word.length + 1 > cWidth) {

var logObject = this.log;
_.forEach(rows, function(row, index) {
logObject.log(level, '║ ' + pad(row.trimRight(), cWidth, padchar) + ' ║');
_.forEach(rows, function(row) {
logObject.log(level, `║ ${pad(row.trimRight(), cWidth, padchar)} ║`);
});

@@ -101,3 +101,3 @@ };

if (!width) width = this.defaultWidth;
this.log.log(level, '╔' + pad('', width - 2, '═') + '╗');
this.log.log(level, `╔${pad('', width - 2, '═')}╗`);
};

@@ -108,3 +108,3 @@

if (!width) width = this.defaultWidth;
this.log.log(level, '╟' + pad('', width - 2, '─') + '╢');
this.log.log(level, `╟${pad('', width - 2, '─')}╢`);
};

@@ -115,3 +115,3 @@

if (!width) width = this.defaultWidth;
this.log.log(level, '╚' + pad('', width - 2, '═') + '╝');
this.log.log(level, `╚${pad('', width - 2, '═')}╝`);
};

@@ -123,3 +123,3 @@

// Find width
var strings = string.split("\n");
var strings = string.split('\n');
var maxWidth = strings.reduce(function (a, b) { return a.length > b.length ? a : b; }).length;

@@ -141,3 +141,3 @@ if (!width)

function pad(value, length, padchar) {
return (value.toString().length < length) ? pad(value+padchar, length, padchar):value;
return (value.toString().length < length) ? pad(value+padchar, length, padchar):value;
}

@@ -161,25 +161,25 @@

function censor(censor) {
var i = 0;
var lastValue;
var i = 0;
var lastValue;
return function(key, value) {
return function(key, value) {
if(i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
if(i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
if(i >= 27) {
// seems to be a harded maximum of 30 serialized objects?
return '[Unknown]';
}
if(i >= 27) {
// seems to be a harded maximum of 30 serialized objects?
return '[Unknown]';
}
// Increment if we're looping, otherwise reset
if (lastValue !== value) {
lastValue = value;
i = 0;
} else {
++i; // so we know we aren't using the original object anymore
// Increment if we're looping, otherwise reset
if (lastValue !== value) {
lastValue = value;
i = 0;
} else {
++i; // so we know we aren't using the original object anymore
}
return value;
};
return value;
};
}

@@ -189,2 +189,2 @@

self = module.exports = Logger;
module.exports = Logger;
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