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

electron-log

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-log - npm Package Compare versions

Comparing version 5.2.3 to 5.2.4

src/core/Buffering.js

2

package.json
{
"name": "electron-log",
"version": "5.2.3",
"version": "5.2.4",
"description": "Just a simple logging module for your Electron application",

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

@@ -251,2 +251,26 @@ # electron-log

### Buffering
It's like a transaction, you may add some logs to the buffer and then decide
whether to write these logs or not. It allows adding verbose logs only
when some operations failed.
```js
import log from 'electron-log/main';
log.buffering.begin();
try {
log.info('First silly message');
// do somethings complex
log.info('Second silly message');
// do something else
// Finished fine, we don't need these logs anymore
log.buffering.reject();
} catch (e) {
log.buffering.commit();
log.warn(e);
}
```
## Related

@@ -253,0 +277,0 @@

'use strict';
const scopeFactory = require('./scope');
const Buffering = require('./Buffering');

@@ -47,2 +48,3 @@ /**

this.allowUnknownLevel = allowUnknownLevel;
this.buffering = new Buffering(this);
this.dependencies = dependencies;

@@ -53,5 +55,5 @@ this.initializeFn = initializeFn;

this.logId = logId;
this.scope = scopeFactory(this);
this.transportFactories = transportFactories;
this.variables = variables || {};
this.scope = scopeFactory(this);

@@ -133,3 +135,7 @@ for (const name of this.levels) {

logData(data, options = {}) {
this.processMessage({ data, ...options });
if (this.buffering.enabled) {
this.buffering.addMessage({ data, ...options });
} else {
this.processMessage({ data, ...options });
}
}

@@ -136,0 +142,0 @@

@@ -369,2 +369,26 @@ import { ClientRequest, RequestOptions } from 'http';

interface Buffering {
/**
* Buffered log messages
*/
buffer: LogMessage[];
enabled: boolean;
/**
* Start buffering log messages
*/
begin(): void;
/**
* Stop buffering and process all buffered logs
*/
commit(): void;
/**
* Stop buffering and discard all buffered logs
*/
reject(): void;
}
interface Scope {

@@ -558,2 +582,7 @@ (label: string): LogFunctions;

/**
* Buffering helper
*/
buffering: Buffering;
/**
* Error handling helper

@@ -560,0 +589,0 @@ */

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