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

@jitsi/logger

Package Overview
Dependencies
Maintainers
10
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jitsi/logger - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

55

lib/LogCollector.js

@@ -70,6 +70,5 @@ /* Copyright @ 2016-present 8x8, Inc.

// in order to implement "global log transport" object.
Object.keys(Logger.levels).forEach(
Object.values(Logger.levels).forEach(
function (logLevel) {
var methodName = Logger.levels[logLevel];
this[methodName] = function () {
this[logLevel] = function () {
this._log.apply(this, arguments);

@@ -141,12 +140,21 @@ }.bind(this, logLevel);

LogCollector.prototype.formatLogMessage = function (
logLevel /* timestamp, arg2, arg3, arg4... */) {
logLevel /* timestamp, arg2, arg3, arg4... */) { // jshint ignore:line
var msg = '';
for (var i = 1, len = arguments.length; i < len; i++) {
var arg = arguments[i];
// objects logged on error level are always converted to JSON
if ((this.stringifyObjects || logLevel === Logger.levels.ERROR) &&
typeof arg === 'object') {
arg = this.stringify(arg);
if (arg instanceof Error) {
msg += arg.toString() + ': ' + arg.stack;
} else if (this.stringifyObjects && typeof arg === 'object') {
// NOTE: We were trying to stringify all error logs before but because of a bug that we were getting the keys
// of the log levels which are all with upper case and comparing it with the keys which are all lower case we
// were never actually strinfying the error logs. That's why I've removed the check for error logs here.
// NOTE: The non-enumerable properties of the objects wouldn't be included in the string after JSON.strigify.
// For example Map instance will be translated to '{}'. So I think we have to eventually do something better
// for parsing the arguments. But since this option for strigify is part of the public interface and I think
// it could be useful in some cases I will it for now.
msg += this.stringify(arg);
} else {
msg += arg;
}
msg += arg;
if (i !== len - 1) {

@@ -227,2 +235,15 @@ msg += ' ';

/**
* Passes the logs to logStorage.storeLogs in order to store them. If logStorage.storeLogs throws an error, it prints it.
* Note: We are not retrying to pass the logs to the logStorage if there is an error.
* @param {string[]} logs - The logs to be stored.
*/
LogCollector.prototype._storeLogs = function (logs) {
try {
this.logStorage.storeLogs(logs);
} catch (error) {
console.error('LogCollector error when calling logStorage.storeLogs(): ', error);
}
};
/**
* Stores the next batch log entry in the log storage.

@@ -239,7 +260,15 @@ * @param {boolean} force enforce current logs batch to be stored or cached if

LogCollector.prototype._flush = function(force, reschedule) {
var logStorageReady = false;
try {
logStorageReady = this.logStorage.isReady();
} catch (error) {
console.error('LogCollector error when calling logStorage.isReady(): ', error);
}
// Publish only if there's anything to be logged
if (this.totalLen > 0 && (this.logStorage.isReady() || force)) {
if (this.totalLen > 0 && (logStorageReady || force)) {
//FIXME avoid truncating
// right now we don't care if the message size is "slightly" exceeded
if (this.logStorage.isReady()) {
if (logStorageReady) {
// Sends all cached logs

@@ -249,3 +278,3 @@ if (this.outputCache.length) {

function (cachedQueue) {
this.logStorage.storeLogs(cachedQueue);
this._storeLogs(cachedQueue);
}.bind(this)

@@ -257,3 +286,3 @@ );

// Send current batch
this.logStorage.storeLogs(this.queue);
this._storeLogs(this.queue);
} else {

@@ -260,0 +289,0 @@ this.outputCache.push(this.queue);

@@ -154,3 +154,9 @@ /* Copyright @ 2015-present 8x8, Inc.

l.bind(t).apply(t, fullLogParts);
try {
l.bind(t).apply(t, fullLogParts);
} catch (error) {
// It would be nice to send the error to the logger but this could send us into an endless loop.
// That's why we use only console for logging here.
console.error("An error occured when trying to log with one of the available transports", error);
}
}

@@ -157,0 +163,0 @@ }

@@ -8,3 +8,3 @@ {

},
"version": "2.0.1",
"version": "2.0.2",
"stability": "unstable",

@@ -11,0 +11,0 @@ "repository": {

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