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

@firebase/logger

Package Overview
Dependencies
Maintainers
4
Versions
3072
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/logger - npm Package Compare versions

Comparing version 0.4.2-canary.46da0930c to 0.4.2-canary.479226bf3

195

dist/index.cjs.js

@@ -5,4 +5,2 @@ 'use strict';

var tslib = require('tslib');
/**

@@ -24,7 +22,6 @@ * @license

*/
var _a;
/**
* A container for all of the Logger instances
*/
var instances = [];
const instances = [];
/**

@@ -50,3 +47,3 @@ * The JS SDK supports 5 log levels and also allows a user the ability to

})(exports.LogLevel || (exports.LogLevel = {}));
var levelStringToEnum = {
const levelStringToEnum = {
'debug': exports.LogLevel.DEBUG,

@@ -62,3 +59,3 @@ 'verbose': exports.LogLevel.VERBOSE,

*/
var defaultLogLevel = exports.LogLevel.INFO;
const defaultLogLevel = exports.LogLevel.INFO;
/**

@@ -70,9 +67,9 @@ * By default, `console.debug` is not displayed in the developer console (in

*/
var ConsoleMethod = (_a = {},
_a[exports.LogLevel.DEBUG] = 'log',
_a[exports.LogLevel.VERBOSE] = 'log',
_a[exports.LogLevel.INFO] = 'info',
_a[exports.LogLevel.WARN] = 'warn',
_a[exports.LogLevel.ERROR] = 'error',
_a);
const ConsoleMethod = {
[exports.LogLevel.DEBUG]: 'log',
[exports.LogLevel.VERBOSE]: 'log',
[exports.LogLevel.INFO]: 'info',
[exports.LogLevel.WARN]: 'warn',
[exports.LogLevel.ERROR]: 'error'
};
/**

@@ -83,20 +80,16 @@ * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR

*/
var defaultLogHandler = function (instance, logType) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
const defaultLogHandler = (instance, logType, ...args) => {
if (logType < instance.logLevel) {
return;
}
var now = new Date().toISOString();
var method = ConsoleMethod[logType];
const now = new Date().toISOString();
const method = ConsoleMethod[logType];
if (method) {
console[method].apply(console, tslib.__spreadArray(["[".concat(now, "] ").concat(instance.name, ":")], args, false));
console[method](`[${now}] ${instance.name}:`, ...args);
}
else {
throw new Error("Attempted to log a message with an invalid logType (value: ".concat(logType, ")"));
throw new Error(`Attempted to log a message with an invalid logType (value: ${logType})`);
}
};
var Logger = /** @class */ (function () {
class Logger {
/**

@@ -108,3 +101,3 @@ * Gives you an instance of a Logger to capture messages according to

*/
function Logger(name) {
constructor(name) {
this.name = name;

@@ -129,89 +122,57 @@ /**

}
Object.defineProperty(Logger.prototype, "logLevel", {
get: function () {
return this._logLevel;
},
set: function (val) {
if (!(val in exports.LogLevel)) {
throw new TypeError("Invalid value \"".concat(val, "\" assigned to `logLevel`"));
}
this._logLevel = val;
},
enumerable: false,
configurable: true
});
get logLevel() {
return this._logLevel;
}
set logLevel(val) {
if (!(val in exports.LogLevel)) {
throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``);
}
this._logLevel = val;
}
// Workaround for setter/getter having to be the same type.
Logger.prototype.setLogLevel = function (val) {
setLogLevel(val) {
this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val;
};
Object.defineProperty(Logger.prototype, "logHandler", {
get: function () {
return this._logHandler;
},
set: function (val) {
if (typeof val !== 'function') {
throw new TypeError('Value assigned to `logHandler` must be a function');
}
this._logHandler = val;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Logger.prototype, "userLogHandler", {
get: function () {
return this._userLogHandler;
},
set: function (val) {
this._userLogHandler = val;
},
enumerable: false,
configurable: true
});
}
get logHandler() {
return this._logHandler;
}
set logHandler(val) {
if (typeof val !== 'function') {
throw new TypeError('Value assigned to `logHandler` must be a function');
}
this._logHandler = val;
}
get userLogHandler() {
return this._userLogHandler;
}
set userLogHandler(val) {
this._userLogHandler = val;
}
/**
* The functions below are all based on the `console` interface
*/
Logger.prototype.debug = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.DEBUG], args, false));
this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.DEBUG], args, false));
};
Logger.prototype.log = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.VERBOSE], args, false));
this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.VERBOSE], args, false));
};
Logger.prototype.info = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.INFO], args, false));
this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.INFO], args, false));
};
Logger.prototype.warn = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.WARN], args, false));
this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.WARN], args, false));
};
Logger.prototype.error = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.ERROR], args, false));
this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.ERROR], args, false));
};
return Logger;
}());
debug(...args) {
this._userLogHandler && this._userLogHandler(this, exports.LogLevel.DEBUG, ...args);
this._logHandler(this, exports.LogLevel.DEBUG, ...args);
}
log(...args) {
this._userLogHandler &&
this._userLogHandler(this, exports.LogLevel.VERBOSE, ...args);
this._logHandler(this, exports.LogLevel.VERBOSE, ...args);
}
info(...args) {
this._userLogHandler && this._userLogHandler(this, exports.LogLevel.INFO, ...args);
this._logHandler(this, exports.LogLevel.INFO, ...args);
}
warn(...args) {
this._userLogHandler && this._userLogHandler(this, exports.LogLevel.WARN, ...args);
this._logHandler(this, exports.LogLevel.WARN, ...args);
}
error(...args) {
this._userLogHandler && this._userLogHandler(this, exports.LogLevel.ERROR, ...args);
this._logHandler(this, exports.LogLevel.ERROR, ...args);
}
}
function setLogLevel(level) {
instances.forEach(function (inst) {
instances.forEach(inst => {
inst.setLogLevel(level);

@@ -221,4 +182,4 @@ });

function setUserLogHandler(logCallback, options) {
var _loop_1 = function (instance) {
var customLogLevel = null;
for (const instance of instances) {
let customLogLevel = null;
if (options && options.level) {

@@ -231,9 +192,5 @@ customLogLevel = levelStringToEnum[options.level];

else {
instance.userLogHandler = function (instance, level) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
var message = args
.map(function (arg) {
instance.userLogHandler = (instance, level, ...args) => {
const message = args
.map(arg => {
if (arg == null) {

@@ -260,3 +217,3 @@ return null;

})
.filter(function (arg) { return arg; })
.filter(arg => arg)
.join(' ');

@@ -266,4 +223,4 @@ if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) {

level: exports.LogLevel[level].toLowerCase(),
message: message,
args: args,
message,
args,
type: instance.name

@@ -274,6 +231,2 @@ });

}
};
for (var _i = 0, instances_1 = instances; _i < instances_1.length; _i++) {
var instance = instances_1[_i];
_loop_1(instance);
}

@@ -280,0 +233,0 @@ }

{
"name": "@firebase/logger",
"version": "0.4.2-canary.46da0930c",
"version": "0.4.2-canary.479226bf3",
"description": "A logger package for use in the Firebase JS SDK",

@@ -8,3 +8,2 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"module": "dist/esm/index.esm2017.js",
"esm5": "dist/esm/index.esm5.js",
"exports": {

@@ -14,3 +13,2 @@ ".": {

"require": "./dist/index.cjs.js",
"esm5": "./dist/esm/index.esm5.js",
"default": "./dist/esm/index.esm2017.js"

@@ -32,3 +30,3 @@ },

"test:all": "run-p --npm-path npm test:browser test:node",
"test:browser": "karma start --single-run",
"test:browser": "karma start",
"test:browser:debug": "karma start --browsers Chrome --auto-watch",

@@ -61,3 +59,6 @@ "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",

"reportDir": "./coverage/node"
},
"engines": {
"node": ">=18.0.0"
}
}

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