New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

logflake

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logflake - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

1

dist/defaults.js

@@ -21,2 +21,3 @@ "use strict";

format: {},
callCount: false,
linebreak: false,

@@ -23,0 +24,0 @@ onLog: function () { },

4

dist/header.js

@@ -27,3 +27,3 @@ "use strict";

var date = this.options.datetime ? this.helpers.getDateTime() : '';
var callCount = _chalk[color](" x" + (_track.callCount || '(?)'));
var callCount = this.options.callCount ? _chalk[color](this.helpers.getCallCountStr(_track)) : '';
var loghash = this.options.showLogHash ? _chalk.gray(" " + _track.hash) : '';

@@ -39,2 +39,4 @@ var header = _chalk[color].bold(headline)

};
Header.prototype.getCallCountStr = function () {
};
return Header;

@@ -41,0 +43,0 @@ }());

@@ -46,2 +46,9 @@ "use strict";

};
Helpers.prototype.getCallCountStr = function (track) {
var callCount = ' x' + (track.callCount || '(?)');
if (track.callCount === Number.MAX_SAFE_INTEGER) {
callCount += ' (+)';
}
return callCount;
};
Helpers.prototype.line = function (colors) {

@@ -48,0 +55,0 @@ if (colors === void 0) { colors = this.options.colors; }

@@ -93,3 +93,12 @@ "use strict";

var trace = new Error().stack.replace('Error\n', '');
cb && cb(output, level, hash, trace);
var date = new Date();
var track = tracker_1.default.read(hash);
cb && cb(output, {
hash: hash,
trace: trace,
level: level,
date: date,
dateUTC: date.toISOString(),
callCount: track.callCount,
});
return keepChain();

@@ -96,0 +105,0 @@ },

@@ -25,3 +25,3 @@ "use strict";

var fnTrack = this.fnPool[hash] || {};
var callCount = fnTrack.callCount ? ++fnTrack.callCount : 1;
var callCount = this.callCountInc(fnTrack.callCount || 0);
if (!fnTrack || fnTrack.fnDisabled !== true) {

@@ -44,2 +44,5 @@ Object.assign(fnTrack, {

};
class_1.prototype.callCountInc = function (callCount) {
return callCount < Number.MAX_SAFE_INTEGER ? ++callCount : callCount;
};
class_1.prototype.mutateFnTrack = function (hash, overrides) {

@@ -46,0 +49,0 @@ var track = this.fnPool[hash];

{
"name": "logflake",
"version": "1.0.1",
"version": "1.1.0",
"description": "Better console messages for NodeJS",

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

@@ -27,3 +27,3 @@ # LogFlake

```
[ CONSOLE ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM x1
[ CONSOLE ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM

@@ -87,3 +87,3 @@ This is an error message

```log
[ CONSOLE LOG ] linux: username (main: test.js) 7/24/2021, 11:34:14 PM x1
[ CONSOLE LOG ] linux: username (main: test.js) 7/24/2021, 11:34:14 PM

@@ -97,4 +97,4 @@ Hello world

```
[ CONSOLE LOG ] linux: username (main: test.js) 7/24/2021, 11:34:14 PM x1
1* 2* 3* 4* 5* 6*
[ CONSOLE LOG ] linux: username (main: test.js) 7/24/2021, 11:34:14 PM
1* 2* 3* 4* 5*
```

@@ -112,6 +112,4 @@

6. How many times this same log() function has been called at the current runtime/process.
You can disable or enable the items `2, 3, 4, 5` on the `LogFlake` options.
You can disable or enable the items `2, 3, 4, 5, 6` on the `LogFlake` options.
### The log() function

@@ -157,3 +155,3 @@

```log
[ CONSOLE ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM x1
[ CONSOLE ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM

@@ -247,2 +245,3 @@ This is an error message

| mainModule | Shows the main module on the log header | true |
| callCount | Shows on header how many times the same log() function has been called at the current runtime/process | false |
| disabled | When true, disables all the logs operations on the current instance | false |

@@ -282,7 +281,7 @@ | seamless | Dont beautify anything, no further info. Use the common console output | false |

```log
[ HELLO LOG ] linux: username (main: test.js) 7/24/2021, 11:45:57 PM x1
[ HELLO LOG ] linux: username (main: test.js) 7/24/2021, 11:45:57 PM
Hello world
··························································································
[ HELLO ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM x1
[ HELLO ERROR ] linux: username (main: test.js) 7/24/2021, 11:46:01 PM

@@ -443,29 +442,30 @@ This is an error message

This function accepts a callback that returns the log `output` and a `info` object. Also accepts a second boolean parameter which gets the `output` with colors; default is `false`. Note: if this very same function has been called 1000 times, the hash will be the same since is a hash per function.
```js
log('error', 'Example').get((output, level, hash, trace) => {
log('error', 'Example').get((output, info) => {
// do whatever you want with the params
// output = complete log output as string
// level = ERROR
// hash = example: 912ec803b2ce49e4a541068d495ab570
// trace = a log trace of this log call
});
```
This function accepts a callback that returns the log `output, level, hash and trace`. Note: if this very same function has been called 1000 times, the hash will be the same since is a hash per function. Your callback will have this signature:
### Callback
The callback has the following signature:
```
cb(output: string, level: string, hash: string, trace: string): unknown
cb(output: string, info: object): unknown
```
The callback params are:
| param | description |
|--|--|--|
| output | the log output as string, with the header, exactly as showed on the console (std) |
| level | the log level (LOG, INFO, ERROR, WARN, TRACE, QUIET) |
| hash | a unique identifier for that log call (the same log call returns the same unique hash) |
| trace | a stack trace of the log call |
| info | an object containing useful information about the triggered log |
### Output
For the given example, the `output` would be the following string:
```
[ CONSOLE ERROR ] linux: username (main: test.js) 7/26/2021, 9:42:49 PM x1
[ CONSOLE ERROR ] linux: username (main: test.js) 7/26/2021, 9:42:49 PM

@@ -476,4 +476,17 @@ Example

This function accepts a second boolean parameter which gets the output with color notations. Default is false.
### Info
The `info` object returns the following properties:
```log
{
hash | the triggered function hash
trace | a stack trace of the triggered log
level | the log level that has been called
date | the current date of the log call
dateUTC | the current UTC date of the log call
callCount | number of times that this same log was triggered
}
```
## fire

@@ -515,3 +528,3 @@

The `onLog` event is available as a Logger Option and accepts a callback that is triggered everytime a log output occurs. The params passed to the callback are `output, level, hash, trace`. It works similar to the `get` method, but its automatically triggered for all log outputs.
The `onLog` event is available as a Logger Option and accepts a callback that is triggered everytime a log output occurs. The params passed to the callback are `output` and `info` containing useful information about the triggered log. It works very similar to the `get` method, but its automatically triggered for all log outputs.

@@ -522,3 +535,3 @@ ```js

const log = logger({
onLog: (output, level, hash, trace) => {
onLog: (output, info) => {
// do whatever you want with the params

@@ -532,6 +545,6 @@ }

On the example above, the `onLog` function callback will be triggered 2 times, passing the `output, level, hash and trace` of the original log functions. Everytime a log is generated with this instance (function), the `onLog` callback will be triggered. Your callback will have this signature:
On the example above, the `onLog` function callback will be triggered 2 times, passing the `output` containing the log contents, and the `info` with information about the log call. Everytime a log is generated with this instance (function), the `onLog` callback will be triggered. Your callback will have this signature:
```
cb(output: string, level: string, hash: string, trace: string): unknown
cb(output: string, info: object): unknown
```

@@ -543,2 +556,2 @@

LogFlake is a `Free and Open Source` package created by Felippe Regazio. Version: 1.0.0.
LogFlake is a `Free and Open Source` package created by Felippe Regazio.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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