initial commit
This commit is contained in:
40
server/node_modules/@firebase/logger/README.md
generated
vendored
Normal file
40
server/node_modules/@firebase/logger/README.md
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# @firebase/logger
|
||||
|
||||
This package serves as the base of all logging in the JS SDK. Any logging that
|
||||
is intended to be visible to Firebase end developers should go through this
|
||||
module.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
Firebase components should import the `Logger` class and instantiate a new
|
||||
instance by passing a component name (e.g. `@firebase/<COMPONENT>`) to the
|
||||
constructor.
|
||||
|
||||
_e.g._
|
||||
|
||||
```typescript
|
||||
import { Logger } from '@firebase/logger';
|
||||
|
||||
const logClient = new Logger(`@firebase/<COMPONENT>`);
|
||||
```
|
||||
|
||||
Each `Logger` instance supports 5 log functions each to be used in a specific
|
||||
instance:
|
||||
|
||||
- `debug`: Internal logs; use this to allow developers to send us their debug
|
||||
logs for us to be able to diagnose an issue.
|
||||
- `log`: Use to inform your user about things they may need to know.
|
||||
- `info`: Use if you have to inform the user about something that they need to
|
||||
take a concrete action on. Once they take that action, the log should go away.
|
||||
- `warn`: Use when a product feature may stop functioning correctly; unexpected
|
||||
scenario.
|
||||
- `error`: Only use when user App would stop functioning correctly - super rare!
|
||||
|
||||
## Log Format
|
||||
|
||||
Each log will be formatted in the following manner:
|
||||
|
||||
```typescript
|
||||
`[${new Date()}] ${COMPONENT_NAME}: ${...args}`
|
||||
```
|
||||
|
||||
17
server/node_modules/@firebase/logger/dist/esm/index.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { setLogLevel, Logger, LogLevel, LogHandler, setUserLogHandler, LogCallback, LogLevelString, LogOptions } from './src/logger';
|
||||
219
server/node_modules/@firebase/logger/dist/esm/index.esm.js
generated
vendored
Normal file
219
server/node_modules/@firebase/logger/dist/esm/index.esm.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* A container for all of the Logger instances
|
||||
*/
|
||||
const instances = [];
|
||||
/**
|
||||
* The JS SDK supports 5 log levels and also allows a user the ability to
|
||||
* silence the logs altogether.
|
||||
*
|
||||
* The order is a follows:
|
||||
* DEBUG < VERBOSE < INFO < WARN < ERROR
|
||||
*
|
||||
* All of the log types above the current log level will be captured (i.e. if
|
||||
* you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
|
||||
* `VERBOSE` logs will not)
|
||||
*/
|
||||
var LogLevel;
|
||||
(function (LogLevel) {
|
||||
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
||||
LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE";
|
||||
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
||||
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
||||
LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
|
||||
LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
|
||||
})(LogLevel || (LogLevel = {}));
|
||||
const levelStringToEnum = {
|
||||
'debug': LogLevel.DEBUG,
|
||||
'verbose': LogLevel.VERBOSE,
|
||||
'info': LogLevel.INFO,
|
||||
'warn': LogLevel.WARN,
|
||||
'error': LogLevel.ERROR,
|
||||
'silent': LogLevel.SILENT
|
||||
};
|
||||
/**
|
||||
* The default log level
|
||||
*/
|
||||
const defaultLogLevel = LogLevel.INFO;
|
||||
/**
|
||||
* By default, `console.debug` is not displayed in the developer console (in
|
||||
* chrome). To avoid forcing users to have to opt-in to these logs twice
|
||||
* (i.e. once for firebase, and once in the console), we are sending `DEBUG`
|
||||
* logs to the `console.log` function.
|
||||
*/
|
||||
const ConsoleMethod = {
|
||||
[LogLevel.DEBUG]: 'log',
|
||||
[LogLevel.VERBOSE]: 'log',
|
||||
[LogLevel.INFO]: 'info',
|
||||
[LogLevel.WARN]: 'warn',
|
||||
[LogLevel.ERROR]: 'error'
|
||||
};
|
||||
/**
|
||||
* The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
|
||||
* messages on to their corresponding console counterparts (if the log method
|
||||
* is supported by the current log level)
|
||||
*/
|
||||
const defaultLogHandler = (instance, logType, ...args) => {
|
||||
if (logType < instance.logLevel) {
|
||||
return;
|
||||
}
|
||||
const now = new Date().toISOString();
|
||||
const method = ConsoleMethod[logType];
|
||||
if (method) {
|
||||
console[method](`[${now}] ${instance.name}:`, ...args);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Attempted to log a message with an invalid logType (value: ${logType})`);
|
||||
}
|
||||
};
|
||||
class Logger {
|
||||
/**
|
||||
* Gives you an instance of a Logger to capture messages according to
|
||||
* Firebase's logging scheme.
|
||||
*
|
||||
* @param name The name that the logs will be associated with
|
||||
*/
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
/**
|
||||
* The log level of the given Logger instance.
|
||||
*/
|
||||
this._logLevel = defaultLogLevel;
|
||||
/**
|
||||
* The main (internal) log handler for the Logger instance.
|
||||
* Can be set to a new function in internal package code but not by user.
|
||||
*/
|
||||
this._logHandler = defaultLogHandler;
|
||||
/**
|
||||
* The optional, additional, user-defined log handler for the Logger instance.
|
||||
*/
|
||||
this._userLogHandler = null;
|
||||
/**
|
||||
* Capture the current instance for later use
|
||||
*/
|
||||
instances.push(this);
|
||||
}
|
||||
get logLevel() {
|
||||
return this._logLevel;
|
||||
}
|
||||
set logLevel(val) {
|
||||
if (!(val in LogLevel)) {
|
||||
throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``);
|
||||
}
|
||||
this._logLevel = val;
|
||||
}
|
||||
// Workaround for setter/getter having to be the same type.
|
||||
setLogLevel(val) {
|
||||
this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val;
|
||||
}
|
||||
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
|
||||
*/
|
||||
debug(...args) {
|
||||
this._userLogHandler && this._userLogHandler(this, LogLevel.DEBUG, ...args);
|
||||
this._logHandler(this, LogLevel.DEBUG, ...args);
|
||||
}
|
||||
log(...args) {
|
||||
this._userLogHandler &&
|
||||
this._userLogHandler(this, LogLevel.VERBOSE, ...args);
|
||||
this._logHandler(this, LogLevel.VERBOSE, ...args);
|
||||
}
|
||||
info(...args) {
|
||||
this._userLogHandler && this._userLogHandler(this, LogLevel.INFO, ...args);
|
||||
this._logHandler(this, LogLevel.INFO, ...args);
|
||||
}
|
||||
warn(...args) {
|
||||
this._userLogHandler && this._userLogHandler(this, LogLevel.WARN, ...args);
|
||||
this._logHandler(this, LogLevel.WARN, ...args);
|
||||
}
|
||||
error(...args) {
|
||||
this._userLogHandler && this._userLogHandler(this, LogLevel.ERROR, ...args);
|
||||
this._logHandler(this, LogLevel.ERROR, ...args);
|
||||
}
|
||||
}
|
||||
function setLogLevel(level) {
|
||||
instances.forEach(inst => {
|
||||
inst.setLogLevel(level);
|
||||
});
|
||||
}
|
||||
function setUserLogHandler(logCallback, options) {
|
||||
for (const instance of instances) {
|
||||
let customLogLevel = null;
|
||||
if (options && options.level) {
|
||||
customLogLevel = levelStringToEnum[options.level];
|
||||
}
|
||||
if (logCallback === null) {
|
||||
instance.userLogHandler = null;
|
||||
}
|
||||
else {
|
||||
instance.userLogHandler = (instance, level, ...args) => {
|
||||
const message = args
|
||||
.map(arg => {
|
||||
if (arg == null) {
|
||||
return null;
|
||||
}
|
||||
else if (typeof arg === 'string') {
|
||||
return arg;
|
||||
}
|
||||
else if (typeof arg === 'number' || typeof arg === 'boolean') {
|
||||
return arg.toString();
|
||||
}
|
||||
else if (arg instanceof Error) {
|
||||
return arg.message;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
return JSON.stringify(arg);
|
||||
}
|
||||
catch (ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(arg => arg)
|
||||
.join(' ');
|
||||
if (level >= (customLogLevel ?? instance.logLevel)) {
|
||||
logCallback({
|
||||
level: LogLevel[level].toLowerCase(),
|
||||
message,
|
||||
args,
|
||||
type: instance.name
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { LogLevel, Logger, setLogLevel, setUserLogHandler };
|
||||
//# sourceMappingURL=index.esm.js.map
|
||||
1
server/node_modules/@firebase/logger/dist/esm/index.esm.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/logger/dist/esm/index.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
server/node_modules/@firebase/logger/dist/esm/package.json
generated
vendored
Normal file
1
server/node_modules/@firebase/logger/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
96
server/node_modules/@firebase/logger/dist/esm/src/logger.d.ts
generated
vendored
Normal file
96
server/node_modules/@firebase/logger/dist/esm/src/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
|
||||
export interface LogOptions {
|
||||
level: LogLevelString;
|
||||
}
|
||||
export type LogCallback = (callbackParams: LogCallbackParams) => void;
|
||||
export interface LogCallbackParams {
|
||||
level: LogLevelString;
|
||||
message: string;
|
||||
args: unknown[];
|
||||
type: string;
|
||||
}
|
||||
/**
|
||||
* A container for all of the Logger instances
|
||||
*/
|
||||
export declare const instances: Logger[];
|
||||
/**
|
||||
* The JS SDK supports 5 log levels and also allows a user the ability to
|
||||
* silence the logs altogether.
|
||||
*
|
||||
* The order is a follows:
|
||||
* DEBUG < VERBOSE < INFO < WARN < ERROR
|
||||
*
|
||||
* All of the log types above the current log level will be captured (i.e. if
|
||||
* you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
|
||||
* `VERBOSE` logs will not)
|
||||
*/
|
||||
export declare enum LogLevel {
|
||||
DEBUG = 0,
|
||||
VERBOSE = 1,
|
||||
INFO = 2,
|
||||
WARN = 3,
|
||||
ERROR = 4,
|
||||
SILENT = 5
|
||||
}
|
||||
/**
|
||||
* We allow users the ability to pass their own log handler. We will pass the
|
||||
* type of log, the current log level, and any other arguments passed (i.e. the
|
||||
* messages that the user wants to log) to this function.
|
||||
*/
|
||||
export type LogHandler = (loggerInstance: Logger, logType: LogLevel, ...args: unknown[]) => void;
|
||||
export declare class Logger {
|
||||
name: string;
|
||||
/**
|
||||
* Gives you an instance of a Logger to capture messages according to
|
||||
* Firebase's logging scheme.
|
||||
*
|
||||
* @param name The name that the logs will be associated with
|
||||
*/
|
||||
constructor(name: string);
|
||||
/**
|
||||
* The log level of the given Logger instance.
|
||||
*/
|
||||
private _logLevel;
|
||||
get logLevel(): LogLevel;
|
||||
set logLevel(val: LogLevel);
|
||||
setLogLevel(val: LogLevel | LogLevelString): void;
|
||||
/**
|
||||
* The main (internal) log handler for the Logger instance.
|
||||
* Can be set to a new function in internal package code but not by user.
|
||||
*/
|
||||
private _logHandler;
|
||||
get logHandler(): LogHandler;
|
||||
set logHandler(val: LogHandler);
|
||||
/**
|
||||
* The optional, additional, user-defined log handler for the Logger instance.
|
||||
*/
|
||||
private _userLogHandler;
|
||||
get userLogHandler(): LogHandler | null;
|
||||
set userLogHandler(val: LogHandler | null);
|
||||
/**
|
||||
* The functions below are all based on the `console` interface
|
||||
*/
|
||||
debug(...args: unknown[]): void;
|
||||
log(...args: unknown[]): void;
|
||||
info(...args: unknown[]): void;
|
||||
warn(...args: unknown[]): void;
|
||||
error(...args: unknown[]): void;
|
||||
}
|
||||
export declare function setLogLevel(level: LogLevelString | LogLevel): void;
|
||||
export declare function setUserLogHandler(logCallback: LogCallback | null, options?: LogOptions): void;
|
||||
17
server/node_modules/@firebase/logger/dist/esm/test/custom-logger.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/esm/test/custom-logger.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/logger/dist/esm/test/logger.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/esm/test/logger.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
225
server/node_modules/@firebase/logger/dist/index.cjs.js
generated
vendored
Normal file
225
server/node_modules/@firebase/logger/dist/index.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* A container for all of the Logger instances
|
||||
*/
|
||||
const instances = [];
|
||||
/**
|
||||
* The JS SDK supports 5 log levels and also allows a user the ability to
|
||||
* silence the logs altogether.
|
||||
*
|
||||
* The order is a follows:
|
||||
* DEBUG < VERBOSE < INFO < WARN < ERROR
|
||||
*
|
||||
* All of the log types above the current log level will be captured (i.e. if
|
||||
* you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
|
||||
* `VERBOSE` logs will not)
|
||||
*/
|
||||
exports.LogLevel = void 0;
|
||||
(function (LogLevel) {
|
||||
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
||||
LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE";
|
||||
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
||||
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
||||
LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
|
||||
LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
|
||||
})(exports.LogLevel || (exports.LogLevel = {}));
|
||||
const levelStringToEnum = {
|
||||
'debug': exports.LogLevel.DEBUG,
|
||||
'verbose': exports.LogLevel.VERBOSE,
|
||||
'info': exports.LogLevel.INFO,
|
||||
'warn': exports.LogLevel.WARN,
|
||||
'error': exports.LogLevel.ERROR,
|
||||
'silent': exports.LogLevel.SILENT
|
||||
};
|
||||
/**
|
||||
* The default log level
|
||||
*/
|
||||
const defaultLogLevel = exports.LogLevel.INFO;
|
||||
/**
|
||||
* By default, `console.debug` is not displayed in the developer console (in
|
||||
* chrome). To avoid forcing users to have to opt-in to these logs twice
|
||||
* (i.e. once for firebase, and once in the console), we are sending `DEBUG`
|
||||
* logs to the `console.log` function.
|
||||
*/
|
||||
const ConsoleMethod = {
|
||||
[exports.LogLevel.DEBUG]: 'log',
|
||||
[exports.LogLevel.VERBOSE]: 'log',
|
||||
[exports.LogLevel.INFO]: 'info',
|
||||
[exports.LogLevel.WARN]: 'warn',
|
||||
[exports.LogLevel.ERROR]: 'error'
|
||||
};
|
||||
/**
|
||||
* The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
|
||||
* messages on to their corresponding console counterparts (if the log method
|
||||
* is supported by the current log level)
|
||||
*/
|
||||
const defaultLogHandler = (instance, logType, ...args) => {
|
||||
if (logType < instance.logLevel) {
|
||||
return;
|
||||
}
|
||||
const now = new Date().toISOString();
|
||||
const method = ConsoleMethod[logType];
|
||||
if (method) {
|
||||
console[method](`[${now}] ${instance.name}:`, ...args);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Attempted to log a message with an invalid logType (value: ${logType})`);
|
||||
}
|
||||
};
|
||||
class Logger {
|
||||
/**
|
||||
* Gives you an instance of a Logger to capture messages according to
|
||||
* Firebase's logging scheme.
|
||||
*
|
||||
* @param name The name that the logs will be associated with
|
||||
*/
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
/**
|
||||
* The log level of the given Logger instance.
|
||||
*/
|
||||
this._logLevel = defaultLogLevel;
|
||||
/**
|
||||
* The main (internal) log handler for the Logger instance.
|
||||
* Can be set to a new function in internal package code but not by user.
|
||||
*/
|
||||
this._logHandler = defaultLogHandler;
|
||||
/**
|
||||
* The optional, additional, user-defined log handler for the Logger instance.
|
||||
*/
|
||||
this._userLogHandler = null;
|
||||
/**
|
||||
* Capture the current instance for later use
|
||||
*/
|
||||
instances.push(this);
|
||||
}
|
||||
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.
|
||||
setLogLevel(val) {
|
||||
this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val;
|
||||
}
|
||||
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
|
||||
*/
|
||||
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(inst => {
|
||||
inst.setLogLevel(level);
|
||||
});
|
||||
}
|
||||
function setUserLogHandler(logCallback, options) {
|
||||
for (const instance of instances) {
|
||||
let customLogLevel = null;
|
||||
if (options && options.level) {
|
||||
customLogLevel = levelStringToEnum[options.level];
|
||||
}
|
||||
if (logCallback === null) {
|
||||
instance.userLogHandler = null;
|
||||
}
|
||||
else {
|
||||
instance.userLogHandler = (instance, level, ...args) => {
|
||||
const message = args
|
||||
.map(arg => {
|
||||
if (arg == null) {
|
||||
return null;
|
||||
}
|
||||
else if (typeof arg === 'string') {
|
||||
return arg;
|
||||
}
|
||||
else if (typeof arg === 'number' || typeof arg === 'boolean') {
|
||||
return arg.toString();
|
||||
}
|
||||
else if (arg instanceof Error) {
|
||||
return arg.message;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
return JSON.stringify(arg);
|
||||
}
|
||||
catch (ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(arg => arg)
|
||||
.join(' ');
|
||||
if (level >= (customLogLevel ?? instance.logLevel)) {
|
||||
logCallback({
|
||||
level: exports.LogLevel[level].toLowerCase(),
|
||||
message,
|
||||
args,
|
||||
type: instance.name
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.Logger = Logger;
|
||||
exports.setLogLevel = setLogLevel;
|
||||
exports.setUserLogHandler = setUserLogHandler;
|
||||
//# sourceMappingURL=index.cjs.js.map
|
||||
1
server/node_modules/@firebase/logger/dist/index.cjs.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/logger/dist/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
server/node_modules/@firebase/logger/dist/index.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { setLogLevel, Logger, LogLevel, LogHandler, setUserLogHandler, LogCallback, LogLevelString, LogOptions } from './src/logger';
|
||||
96
server/node_modules/@firebase/logger/dist/src/logger.d.ts
generated
vendored
Normal file
96
server/node_modules/@firebase/logger/dist/src/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
|
||||
export interface LogOptions {
|
||||
level: LogLevelString;
|
||||
}
|
||||
export type LogCallback = (callbackParams: LogCallbackParams) => void;
|
||||
export interface LogCallbackParams {
|
||||
level: LogLevelString;
|
||||
message: string;
|
||||
args: unknown[];
|
||||
type: string;
|
||||
}
|
||||
/**
|
||||
* A container for all of the Logger instances
|
||||
*/
|
||||
export declare const instances: Logger[];
|
||||
/**
|
||||
* The JS SDK supports 5 log levels and also allows a user the ability to
|
||||
* silence the logs altogether.
|
||||
*
|
||||
* The order is a follows:
|
||||
* DEBUG < VERBOSE < INFO < WARN < ERROR
|
||||
*
|
||||
* All of the log types above the current log level will be captured (i.e. if
|
||||
* you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
|
||||
* `VERBOSE` logs will not)
|
||||
*/
|
||||
export declare enum LogLevel {
|
||||
DEBUG = 0,
|
||||
VERBOSE = 1,
|
||||
INFO = 2,
|
||||
WARN = 3,
|
||||
ERROR = 4,
|
||||
SILENT = 5
|
||||
}
|
||||
/**
|
||||
* We allow users the ability to pass their own log handler. We will pass the
|
||||
* type of log, the current log level, and any other arguments passed (i.e. the
|
||||
* messages that the user wants to log) to this function.
|
||||
*/
|
||||
export type LogHandler = (loggerInstance: Logger, logType: LogLevel, ...args: unknown[]) => void;
|
||||
export declare class Logger {
|
||||
name: string;
|
||||
/**
|
||||
* Gives you an instance of a Logger to capture messages according to
|
||||
* Firebase's logging scheme.
|
||||
*
|
||||
* @param name The name that the logs will be associated with
|
||||
*/
|
||||
constructor(name: string);
|
||||
/**
|
||||
* The log level of the given Logger instance.
|
||||
*/
|
||||
private _logLevel;
|
||||
get logLevel(): LogLevel;
|
||||
set logLevel(val: LogLevel);
|
||||
setLogLevel(val: LogLevel | LogLevelString): void;
|
||||
/**
|
||||
* The main (internal) log handler for the Logger instance.
|
||||
* Can be set to a new function in internal package code but not by user.
|
||||
*/
|
||||
private _logHandler;
|
||||
get logHandler(): LogHandler;
|
||||
set logHandler(val: LogHandler);
|
||||
/**
|
||||
* The optional, additional, user-defined log handler for the Logger instance.
|
||||
*/
|
||||
private _userLogHandler;
|
||||
get userLogHandler(): LogHandler | null;
|
||||
set userLogHandler(val: LogHandler | null);
|
||||
/**
|
||||
* The functions below are all based on the `console` interface
|
||||
*/
|
||||
debug(...args: unknown[]): void;
|
||||
log(...args: unknown[]): void;
|
||||
info(...args: unknown[]): void;
|
||||
warn(...args: unknown[]): void;
|
||||
error(...args: unknown[]): void;
|
||||
}
|
||||
export declare function setLogLevel(level: LogLevelString | LogLevel): void;
|
||||
export declare function setUserLogHandler(logCallback: LogCallback | null, options?: LogOptions): void;
|
||||
17
server/node_modules/@firebase/logger/dist/test/custom-logger.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/test/custom-logger.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/logger/dist/test/logger.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/logger/dist/test/logger.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
60
server/node_modules/@firebase/logger/package.json
generated
vendored
Normal file
60
server/node_modules/@firebase/logger/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "@firebase/logger",
|
||||
"version": "0.5.0",
|
||||
"description": "A logger package for use in the Firebase JS SDK",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/esm/index.esm.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs.js",
|
||||
"default": "./dist/esm/index.esm.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"build": "rollup -c",
|
||||
"build:deps": "lerna run --scope @firebase/logger --include-dependencies build",
|
||||
"dev": "rollup -c -w",
|
||||
"test": "run-p --npm-path npm lint test:all",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
|
||||
"test:all": "run-p --npm-path npm test:browser test:node",
|
||||
"test:browser": "karma start",
|
||||
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
|
||||
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
|
||||
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rollup": "2.79.2",
|
||||
"rollup-plugin-typescript2": "0.36.0",
|
||||
"typescript": "5.5.4"
|
||||
},
|
||||
"repository": {
|
||||
"directory": "packages/logger",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"typings": "dist/index.d.ts",
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"reportDir": "./coverage/node"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user